Sha256: fa513c99acc0787ea0c782b82b6be8e5d95b0d4c1c44dc18f219e197fce23791

Contents?: true

Size: 961 Bytes

Versions: 2

Compression:

Stored size: 961 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

2 entries across 2 versions & 1 rubygems

Version Path
koi-reference-parser-0.0.3 test/unit/flow_control/if_test.rb
koi-reference-parser-0.0.2 test/parser/unit/if_test.rb