Sha256: 06c7cbc775f5b545e54347364fd6f8f48449621ce4c73c406dcc33d8cefedf4d

Contents?: true

Size: 965 Bytes

Versions: 2

Compression:

Stored size: 965 Bytes

Contents

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

class FunctionDefinitionTest < Test::Unit::TestCase

  include KoiReferenceParser

  test "should parse function definition including it's statements" do
    tree = Parser.parse("test = function(args)\n  teest1 = 1\n  test2 = 2\nend")
    assert_kind_of Block, tree
    assert_kind_of Statement, tree.elements.first
    assert_kind_of Assignment, tree.elements.first.elements.first
    assert_kind_of FunctionDefinition, tree.elements.first.elements.first.elements.last
    assert_kind_of Identifier, tree.elements.first.elements.first.elements.last.elements.first
    assert_kind_of Block, tree.elements.first.elements.first.elements.last.elements.last
    assert_kind_of Statement, tree.elements.first.elements.first.elements.last.elements.last.elements[0]
    assert_kind_of Statement, tree.elements.first.elements.first.elements.last.elements.last.elements[1]
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
koi-reference-parser-0.0.3 test/unit/functions/function_definition_test.rb
koi-reference-parser-0.0.2 test/parser/unit/function_definition_test.rb