babel_bridge 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +6 -0
- data/lib/nodes.rb +1 -1
- data/lib/nodes/empty_node.rb +1 -20
- data/lib/nodes/node.rb +33 -32
- data/lib/nodes/non_terminal_node.rb +10 -13
- data/lib/nodes/root_node.rb +4 -0
- data/lib/nodes/rule_node.rb +97 -44
- data/lib/nodes/terminal_node.rb +3 -3
- data/lib/parser.rb +95 -61
- data/lib/pattern_element.rb +71 -43
- data/lib/rule.rb +12 -6
- data/lib/rule_variant.rb +39 -15
- data/lib/string.rb +2 -9
- data/lib/tools.rb +26 -6
- data/lib/version.rb +2 -1
- data/spec/advanced_parsers_spec.rb +49 -0
- data/spec/basic_parsing_spec.rb +94 -0
- data/spec/bb_spec.rb +7 -163
- data/spec/ignore_whitespace_spec.rb +227 -0
- data/spec/inspect_spec.rb +50 -0
- data/spec/many_spec.rb +60 -0
- data/spec/node_spec.rb +117 -0
- data/spec/pattern_generators_spec.rb +41 -0
- data/spec/rule_parsing_spec.rb +61 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/tools_spec.rb +21 -0
- metadata +13 -4
- data/lib/nodes/many_node.rb +0 -53
- data/test/test_bb.rb +0 -458
- data/test/test_helper.rb +0 -44
data/test/test_helper.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
class TestHelper
|
2
|
-
class AssertionFailure < Exception
|
3
|
-
end
|
4
|
-
def assert(val)
|
5
|
-
raise AssertionFailure.new("assertion failed: expected a value, got #{val.inspect}") unless val
|
6
|
-
end
|
7
|
-
|
8
|
-
def assert_nil(val)
|
9
|
-
raise AssertionFailure.new("assertion failed: did not expect a value, got #{val.inspect}") if val
|
10
|
-
end
|
11
|
-
|
12
|
-
def assert_equal(expected,val)
|
13
|
-
raise AssertionFailure.new("expected #{expected.inspect}; got #{val.inspect}") if expected!=val
|
14
|
-
end
|
15
|
-
|
16
|
-
def run_tests(tests=nil)
|
17
|
-
failures=[]
|
18
|
-
errors=[]
|
19
|
-
successes=0
|
20
|
-
(tests || self.methods).each do |method|
|
21
|
-
method=method.to_sym
|
22
|
-
if method.to_s[/^test_/]
|
23
|
-
begin
|
24
|
-
self.send(method)
|
25
|
-
successes+=1
|
26
|
-
$stdout.write(".");
|
27
|
-
rescue AssertionFailure => e
|
28
|
-
errors<<"#{method} failed an assertion: #{e}"+
|
29
|
-
" "+e.backtrace.join("\n ")+"\n\n"
|
30
|
-
$stdout.write("E");
|
31
|
-
rescue Exception => e
|
32
|
-
failures<<"#{method} had an error: #{e}"+
|
33
|
-
" "+e.backtrace.join("\n ")+"\n\n"
|
34
|
-
$stdout.write("F");
|
35
|
-
end
|
36
|
-
$stdout.flush()
|
37
|
-
end
|
38
|
-
end
|
39
|
-
puts ""
|
40
|
-
puts "\n\n"+(errors+failures).join("\n\n")
|
41
|
-
puts "successes: #{successes}, failures: #{failures.length}, errors: #{errors.length}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|