# frozen_string_literal: true

# Autogenerated code. This code was generated by bin/gen-specs.rb. DO NOT EDIT.
# Edits will be lost once the generator is run again.

RSpec.describe "css-parsing-tests: stylesheet.json" do
  it "parses \"\"" do
    style = ""
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      empty!
    end
  end

  it "parses \"foo\"" do
    style = "foo"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      consume_error("invalid")
    end
  end

  it "parses \"foo 4\"" do
    style = "foo 4"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      consume_error("invalid")
    end
  end

  it "parses \"@foo\"" do
    style = "@foo"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      at_rule("foo") do
        prelude do
          empty!
        end
      end
    end
  end

  it "parses \"@foo bar; \\t/* comment */\"" do
    style = "@foo bar; \t/* comment */"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      at_rule("foo") do
        prelude do
          ident "bar"
        end
      end
    end
  end

  it "parses \" /**/ @foo bar{[(4\"" do
    style = " /**/ @foo bar{[(4"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      at_rule("foo") do
        prelude do
          ident "bar"
        end
      end
    end
  end

  it "parses \"@foo { bar\"" do
    style = "@foo { bar"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      at_rule("foo") do
        prelude do
          empty!
        end
      end
    end
  end

  it "parses \"@foo [ bar\"" do
    style = "@foo [ bar"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      at_rule("foo") do
        prelude do
          block("[") do
            delim " "
            ident "bar"
          end
        end
      end
    end
  end

  it "parses \" /**/ div > p { color: #aaa;  } /**/ \"" do
    style = " /**/ div > p { color: #aaa;  } /**/ "
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      q_rule do
        prelude do
          ident "div"
          delim " "
          delim ">"
          delim " "
          ident "p"
          delim " "
        end
        body do
          decl("color", important: false) do
            string "#aaa"
          end
        end
      end
    end
  end

  it "parses \" /**/ { color: #aaa  \"" do
    style = " /**/ { color: #aaa  "
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      q_rule do
        prelude do
          empty!
        end
        body do
          decl("color", important: false) do
            string "#aaa"
          end
        end
      end
    end
  end

  it "parses \" /* CDO/CDC are ignored between rules */ <!-- --> {\"" do
    style = " /* CDO/CDC are ignored between rules */ <!-- --> {"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      q_rule do
        prelude do
          empty!
        end
        body do
          empty!
        end
      end
    end
  end

  it "parses \" <!-- --> a<!---->{\"" do
    style = " <!-- --> a<!---->{"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      q_rule do
        prelude do
          ident "a"
          delim "<!--"
          delim "-->"
        end
        body do
          empty!
        end
      end
    end
  end

  it "parses \"div { color: #aaa; } p{}\"" do
    style = "div { color: #aaa; } p{}"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      q_rule do
        prelude do
          ident "div"
        end
        body do
          decl("color", important: false) do
            string "#aaa"
          end
        end
      end
      q_rule do
        prelude do
          ident "p"
        end
        body do
          empty!
        end
      end
    end
  end

  it "parses \"div {} -->\"" do
    style = "div {} -->"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      q_rule do
        prelude do
          ident "div"
        end
        body do
          empty!
        end
      end
    end
  end

  it "parses \"{}a\"" do
    style = "{}a"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      q_rule do
        prelude do
          empty!
        end
        body do
          empty!
        end
      end
      consume_error("invalid")
    end
  end

  it "parses \"{}@a\"" do
    style = "{}@a"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_stylesheet
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      q_rule do
        prelude do
          empty!
        end
        body do
          empty!
        end
      end
      at_rule("a") do
        prelude do
          empty!
        end
      end
    end
  end

end