# 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: blocks_contents.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_block_contents
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      empty!
    end
  end

  it "parses \"a:b; c:d 42!important;\\n\"" do
    style = "a:b; c:d 42!important;\n"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_block_contents
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      decl("a", important: false) do
        ident "b"
      end
      decl("c", important: true) do
        ident "d"
        delim " "
        number 42, :integer
      end
    end
  end

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

    match_ast(r) do
      consume_error("invalid")
      decl("a", important: false) do
        ident "b"
      end
    end
  end

  it "parses \"z:x!;a:b\"" do
    style = "z:x!;a:b"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_block_contents
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      decl("z", important: false) do
        ident "x"
        delim "!"
      end
      decl("a", important: false) do
        ident "b"
      end
    end
  end

  it "parses \"a:b; c+:d\"" do
    style = "a:b; c+:d"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_block_contents
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      decl("a", important: false) do
        ident "b"
      end
      consume_error("invalid")
    end
  end

  it "parses \"@import 'foo.css'; a:b; @import 'bar.css'\"" do
    style = "@import 'foo.css'; a:b; @import 'bar.css'"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_block_contents
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      at_rule("import") do
        prelude do
          string "foo.css"
        end
      end
      decl("a", important: false) do
        ident "b"
      end
      at_rule("import") do
        prelude do
          string "bar.css"
        end
      end
    end
  end

  it "parses \"@media screen { div{;}} a:b;; @media print{div{\"" do
    style = "@media screen { div{;}} a:b;; @media print{div{"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_block_contents
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      at_rule("media") do
        prelude do
          ident "screen"
        end
      end
      decl("a", important: false) do
        ident "b"
      end
      at_rule("media") do
        prelude do
          ident "print"
        end
      end
    end
  end

  it "parses \"@ media screen { div{;}} a:b;; @media print{div{\"" do
    style = "@ media screen { div{;}} a:b;; @media print{div{"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_block_contents
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      q_rule do
        prelude do
          delim "@"
          delim " "
          ident "media"
          delim " "
          ident "screen"
        end
        body do
          q_rule do
            prelude do
              string "div"
            end
            body do
              empty!
            end
          end
        end
      end
      decl("a", important: false) do
        ident "b"
      end
      at_rule("media") do
        prelude do
          ident "print"
        end
      end
    end
  end

  it "parses \"z:x;a b{c:d;;e:f}\"" do
    style = "z:x;a b{c:d;;e:f}"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_block_contents
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      decl("z", important: false) do
        ident "x"
      end
      q_rule do
        prelude do
          ident "a"
          delim " "
          ident "b"
        end
        body do
          decl("c", important: false) do
            ident "d"
          end
          decl("e", important: false) do
            ident "e"
          end
        end
      end
    end
  end

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

    match_ast(r) do
      q_rule do
        prelude do
          ident "a"
        end
        body do
          decl("c", important: false) do
            number 1, :integer
          end
        end
      end
    end
  end

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

    match_ast(r) do
      q_rule do
        prelude do
          ident "a"
          delim ":"
          ident "hover"
        end
        body do
          decl("c", important: false) do
            number 1, :integer
          end
        end
      end
    end
  end

  it "parses \"z:x;a b{c:d}e:f\"" do
    style = "z:x;a b{c:d}e:f"
    tok = MiniCSS::CSS::Tokenizer.new(style, allow_unicode_ranges: true)
    tok.tokenize
    par = MiniCSS::CSS::Parser.new(tok.tokens)
    sheet = par.parse_block_contents
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      decl("z", important: false) do
        ident "x"
      end
      q_rule do
        prelude do
          ident "a"
          delim " "
          ident "b"
        end
        body do
          decl("c", important: false) do
            ident "d"
          end
        end
      end
      decl("e", important: false) do
        ident "f"
      end
    end
  end

  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_block_contents
    r = MiniCSS::AST.convert(sheet)

    match_ast(r) do
      empty!
    end
  end

end