Sha256: c7d8186800df6b24e87c2988b3bbea9ff64e95d565d5d1b4f1d1d00c4e71614d

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))

class IfTest < Test::Unit::TestCase

  include KoiReferenceParser

  test "should parse if statement" do
    tree = Parser.parse("if(1 == 1)\n test = 1\nend")
    assert_kind_of Block, tree
    assert_kind_of Statement, tree.elements.first
    assert_kind_of If, tree.elements.first.elements.first
    assert_kind_of Expression, tree.elements.first.elements.first.elements.first
    assert_kind_of Block, tree.elements.first.elements.first.elements.last
  end
  
  test "should parse single line if statement" do
    tree = Parser.parse("if(1 == 1) test = 1; end")
    assert_kind_of Block, tree
    assert_kind_of Statement, tree.elements.first
    assert_kind_of If, tree.elements.first.elements.first
    assert_kind_of Expression, tree.elements.first.elements.first.elements.first
    assert_kind_of Block, tree.elements.first.elements.first.elements.last
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
koi-reference-parser-0.0.1 test/parser/unit/if_test.rb