Sha256: 9354514e162bcd40b3c1a4f61236d9c70656fdb2929118fd3280dfdee928ccc9

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require "spec_helper"

describe Liquidscript::Scanner::Liquidscript, :lexer_helper do

  describe "#perform" do
    it "scans a number" do
      expect(scan("43")).to eq [
        [:number, "43"]
      ]
    end

    it "scans a string" do
      scan('"hello world" ').should eq [
        [:istring, 'hello world']
      ]

      scan(" 'foobar").should eq [
        [:sstring, "'foobar"]
      ]

      scan('"hello #{world}"').should eq [
        [:istring_begin, "hello "],
        [:identifier, "world"],
        [:istring, ""]
      ]
    end

    it "scans an identifier" do
      scan('test = 4').should eq [
        [:identifier, "test"],
        [:equal, nil],
        [:number, "4"]
      ]
    end

    it "scans brackets" do
      scan("{ test = 3 }").should eq [
        [:lbrack, nil],
        [:identifier, "test"],
        [:equal, nil],
        [:number, "3"],
        [:rbrack, nil]
      ]
    end

    it "scans keywords" do
      scan("return test = new foo").should eq [
        [:unop, "return"],
        [:identifier, "test"],
        [:equal, nil],
        [:unop, "new"],
        [:identifier, "foo"]
      ]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
liquidscript-0.4.1 spec/liquidscript/scanner/lexer_spec.rb
liquidscript-0.4.0 spec/liquidscript/scanner/lexer_spec.rb