koi-reference-parser 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,43 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class SyntaxNodeToHashTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "should convert SyntaxNode to hash" do
8
+ input = "test = 1"
9
+ tree = Identifier.new(input, 0...4)
10
+ hash = tree.to_hash
11
+ assert_equal( {
12
+ :elements => nil,
13
+ :offset => 0,
14
+ :name => "Identifier",
15
+ :text_value => "test"
16
+ }, hash )
17
+ end
18
+
19
+ test "should convert SyntaxNode to hash including elements" do
20
+ input = "test = 1"
21
+ tree = Assignment.new(input, 0...8, [
22
+ Identifier.new(input, 0...4)
23
+ ])
24
+ hash = tree.to_hash
25
+ built_hash = {
26
+ :elements => nil,
27
+ :offset => 0,
28
+ :name => "Assignment",
29
+ :text_value => "test = 1"
30
+ }
31
+ built_hash[:elements] = [
32
+ {
33
+ :elements => nil,
34
+ :offset => 0,
35
+ :name => "Identifier",
36
+ :text_value => "test"
37
+ }
38
+ ]
39
+ assert_equal( built_hash, hash )
40
+ end
41
+
42
+
43
+ end
@@ -1,25 +1,25 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
-
3
- class UnlessTest < Test::Unit::TestCase
4
-
5
- include KoiReferenceParser
6
-
7
- test "should parse unless statement" do
8
- tree = Parser.parse("unless(1 == 1)\n test = 1\nend")
9
- assert_kind_of Block, tree
10
- assert_kind_of Statement, tree.elements.first
11
- assert_kind_of Unless, tree.elements.first.elements.first
12
- assert_kind_of Expression, tree.elements.first.elements.first.elements.first
13
- assert_kind_of Block, tree.elements.first.elements.first.elements.last
14
- end
15
-
16
- test "should parse single line unless statement" do
17
- tree = Parser.parse("unless(1 == 1) test = 1; end")
18
- assert_kind_of Block, tree
19
- assert_kind_of Statement, tree.elements.first
20
- assert_kind_of Unless, tree.elements.first.elements.first
21
- assert_kind_of Expression, tree.elements.first.elements.first.elements.first
22
- assert_kind_of Block, tree.elements.first.elements.first.elements.last
23
- end
24
-
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper.rb'))
2
+
3
+ class UnlessTest < Test::Unit::TestCase
4
+
5
+ include KoiReferenceParser
6
+
7
+ test "should parse unless statement" do
8
+ tree = Parser.parse("unless(1 == 1)\n test = 1\nend")
9
+ assert_kind_of Block, tree
10
+ assert_kind_of Statement, tree.elements.first
11
+ assert_kind_of Unless, tree.elements.first.elements.first
12
+ assert_kind_of Expression, tree.elements.first.elements.first.elements.first
13
+ assert_kind_of Block, tree.elements.first.elements.first.elements.last
14
+ end
15
+
16
+ test "should parse single line unless statement" do
17
+ tree = Parser.parse("unless(1 == 1) test = 1; end")
18
+ assert_kind_of Block, tree
19
+ assert_kind_of Statement, tree.elements.first
20
+ assert_kind_of Unless, tree.elements.first.elements.first
21
+ assert_kind_of Expression, tree.elements.first.elements.first.elements.first
22
+ assert_kind_of Block, tree.elements.first.elements.first.elements.last
23
+ end
24
+
25
25
  end
@@ -1,21 +1,21 @@
1
- module Test::Unit
2
- # Used to fix a minor minitest/unit incompatibility in flexmock
3
- AssertionFailedError = Class.new(StandardError)
4
-
5
- class TestCase
6
-
7
- def self.test(name, &block)
8
- test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
9
- defined = instance_method(test_name) rescue false
10
- raise "#{test_name} is already defined in #{self}" if defined
11
- if block_given?
12
- define_method(test_name, &block)
13
- else
14
- define_method(test_name) do
15
- flunk "No implementation provided for #{name}"
16
- end
17
- end
18
- end
19
-
20
- end
1
+ module Test::Unit
2
+ # Used to fix a minor minitest/unit incompatibility in flexmock
3
+ AssertionFailedError = Class.new(StandardError)
4
+
5
+ class TestCase
6
+
7
+ def self.test(name, &block)
8
+ test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
9
+ defined = instance_method(test_name) rescue false
10
+ raise "#{test_name} is already defined in #{self}" if defined
11
+ if block_given?
12
+ define_method(test_name, &block)
13
+ else
14
+ define_method(test_name) do
15
+ flunk "No implementation provided for #{name}"
16
+ end
17
+ end
18
+ end
19
+
20
+ end
21
21
  end
@@ -1,10 +1,10 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
-
4
- require_files = []
5
- require_files << File.join(File.dirname(__FILE__), '..', 'lib', 'koi-reference-parser.rb')
6
- require_files.concat Dir[File.join(File.dirname(__FILE__), 'setup', '*.rb')]
7
-
8
- require_files.each do |file|
9
- require File.expand_path(file)
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ require_files = []
5
+ require_files << File.join(File.dirname(__FILE__), '..', 'lib', 'koi-reference-parser.rb')
6
+ require_files.concat Dir[File.join(File.dirname(__FILE__), 'setup', '*.rb')]
7
+
8
+ require_files.each do |file|
9
+ require File.expand_path(file)
10
10
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Gough
@@ -14,13 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-30 00:00:00 -04:00
17
+ date: 2010-08-31 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: treetop
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
@@ -43,10 +44,12 @@ files:
43
44
  - MIT-LICENSE
44
45
  - README.rdoc
45
46
  - Rakefile
47
+ - VERSION
46
48
  - lib/koi-reference-parser.rb
47
49
  - lib/parser/exceptions.rb
48
50
  - lib/parser/koi-reference-parser.treetop
49
51
  - lib/parser/parser.rb
52
+ - lib/parser/syntax_node_extensions.rb
50
53
  - lib/parser/syntax_nodes.rb
51
54
  - test/parser/functional/function_call_as_argument.rb
52
55
  - test/parser/functional/simple_program_test.rb
@@ -59,6 +62,7 @@ files:
59
62
  - test/parser/unit/if_test.rb
60
63
  - test/parser/unit/simple_expression_test.rb
61
64
  - test/parser/unit/statement_test.rb
65
+ - test/parser/unit/syntax_node_to_hash_test.rb
62
66
  - test/parser/unit/unless_test.rb
63
67
  - test/setup/test_unit_extensions.rb
64
68
  - test/test_helper.rb
@@ -74,6 +78,7 @@ rdoc_options:
74
78
  require_paths:
75
79
  - lib
76
80
  required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
77
82
  requirements:
78
83
  - - ">="
79
84
  - !ruby/object:Gem::Version
@@ -81,6 +86,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
86
  - 0
82
87
  version: "0"
83
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
84
90
  requirements:
85
91
  - - ">="
86
92
  - !ruby/object:Gem::Version
@@ -90,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
96
  requirements: []
91
97
 
92
98
  rubyforge_project:
93
- rubygems_version: 1.3.6
99
+ rubygems_version: 1.3.7
94
100
  signing_key:
95
101
  specification_version: 3
96
102
  summary: A reference parser for the Koi language.
@@ -106,6 +112,7 @@ test_files:
106
112
  - test/parser/unit/if_test.rb
107
113
  - test/parser/unit/simple_expression_test.rb
108
114
  - test/parser/unit/statement_test.rb
115
+ - test/parser/unit/syntax_node_to_hash_test.rb
109
116
  - test/parser/unit/unless_test.rb
110
117
  - test/setup/test_unit_extensions.rb
111
118
  - test/test_helper.rb