mail 2.1.5.2 → 2.1.5.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mail might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +6 -0
- data/Rakefile +2 -1
- data/lib/mail.rb +0 -1
- data/lib/mail/elements.rb +0 -1
- data/lib/mail/utilities.rb +1 -1
- data/lib/mail/version.rb +1 -1
- data/lib/tasks/treetop.rake +4 -4
- metadata +17 -129
- data/lib/mail/vendor/treetop-1.4.4/History.txt +0 -18
- data/lib/mail/vendor/treetop-1.4.4/LICENSE +0 -19
- data/lib/mail/vendor/treetop-1.4.4/README.md +0 -164
- data/lib/mail/vendor/treetop-1.4.4/Rakefile +0 -28
- data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Preferences/Comments.tmPreferences +0 -22
- data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Snippets/grammar ___ end.tmSnippet +0 -20
- data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Snippets/rule ___ end.tmSnippet +0 -18
- data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/designable.nib +0 -1524
- data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Support/nibs/SyntaxTreeViewer.nib/keyedobjects.nib +0 -0
- data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Support/syntax_tree_viewer.rb +0 -117
- data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/Syntaxes/Treetop Grammar.tmLanguage +0 -278
- data/lib/mail/vendor/treetop-1.4.4/Treetop.tmbundle/info.plist +0 -10
- data/lib/mail/vendor/treetop-1.4.4/benchmark/seqpar.gnuplot +0 -15
- data/lib/mail/vendor/treetop-1.4.4/benchmark/seqpar.treetop +0 -16
- data/lib/mail/vendor/treetop-1.4.4/benchmark/seqpar_benchmark.rb +0 -107
- data/lib/mail/vendor/treetop-1.4.4/bin/tt +0 -112
- data/lib/mail/vendor/treetop-1.4.4/doc/contributing_and_planned_features.markdown +0 -103
- data/lib/mail/vendor/treetop-1.4.4/doc/grammar_composition.markdown +0 -65
- data/lib/mail/vendor/treetop-1.4.4/doc/index.markdown +0 -90
- data/lib/mail/vendor/treetop-1.4.4/doc/pitfalls_and_advanced_techniques.markdown +0 -51
- data/lib/mail/vendor/treetop-1.4.4/doc/semantic_interpretation.markdown +0 -189
- data/lib/mail/vendor/treetop-1.4.4/doc/site.rb +0 -112
- data/lib/mail/vendor/treetop-1.4.4/doc/sitegen.rb +0 -65
- data/lib/mail/vendor/treetop-1.4.4/doc/syntactic_recognition.markdown +0 -100
- data/lib/mail/vendor/treetop-1.4.4/doc/using_in_ruby.markdown +0 -28
- data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/arithmetic.rb +0 -551
- data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/arithmetic.treetop +0 -97
- data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/arithmetic_node_classes.rb +0 -7
- data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/arithmetic_test.rb +0 -54
- data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/lambda_calculus +0 -0
- data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/lambda_calculus.rb +0 -718
- data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/lambda_calculus.treetop +0 -132
- data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/lambda_calculus_node_classes.rb +0 -5
- data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/lambda_calculus_test.rb +0 -89
- data/lib/mail/vendor/treetop-1.4.4/examples/lambda_calculus/test_helper.rb +0 -18
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop.rb +0 -3
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/bootstrap_gen_1_metagrammar.rb +0 -42
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler.rb +0 -7
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/grammar_compiler.rb +0 -44
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/lexical_address_space.rb +0 -17
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/metagrammar.rb +0 -3366
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/metagrammar.treetop +0 -436
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes.rb +0 -19
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/anything_symbol.rb +0 -18
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/atomic_expression.rb +0 -14
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/character_class.rb +0 -28
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/choice.rb +0 -31
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/declaration_sequence.rb +0 -24
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/grammar.rb +0 -28
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/inline_module.rb +0 -27
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/nonterminal.rb +0 -13
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/optional.rb +0 -19
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/parenthesized_expression.rb +0 -9
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/parsing_expression.rb +0 -146
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/parsing_rule.rb +0 -58
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/predicate.rb +0 -45
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/predicate_block.rb +0 -16
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/repetition.rb +0 -55
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/sequence.rb +0 -71
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/terminal.rb +0 -20
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/transient_prefix.rb +0 -9
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/node_classes/treetop_file.rb +0 -9
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/compiler/ruby_builder.rb +0 -113
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/polyglot.rb +0 -9
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/ruby_extensions.rb +0 -1
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/ruby_extensions/string.rb +0 -42
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime.rb +0 -6
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/compiled_parser.rb +0 -110
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/interval_skip_list.rb +0 -3
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/interval_skip_list/head_node.rb +0 -15
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb +0 -200
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/interval_skip_list/node.rb +0 -164
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/syntax_node.rb +0 -114
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/terminal_parse_failure.rb +0 -16
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/runtime/terminal_syntax_node.rb +0 -17
- data/lib/mail/vendor/treetop-1.4.4/lib/treetop/version.rb +0 -9
- data/lib/mail/vendor/treetop-1.4.4/script/generate_metagrammar.rb +0 -13
- data/lib/mail/vendor/treetop-1.4.4/script/svnadd +0 -11
- data/lib/mail/vendor/treetop-1.4.4/script/svnrm +0 -11
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/and_predicate_spec.rb +0 -36
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/anything_symbol_spec.rb +0 -44
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/character_class_spec.rb +0 -276
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/choice_spec.rb +0 -80
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/circular_compilation_spec.rb +0 -30
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/failure_propagation_functional_spec.rb +0 -21
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/grammar_compiler_spec.rb +0 -84
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/grammar_spec.rb +0 -41
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/multibyte_chars_spec.rb +0 -38
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/nonterminal_symbol_spec.rb +0 -40
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/not_predicate_spec.rb +0 -38
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/one_or_more_spec.rb +0 -35
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/optional_spec.rb +0 -37
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/parenthesized_expression_spec.rb +0 -19
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/parsing_rule_spec.rb +0 -61
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/repeated_subrule_spec.rb +0 -29
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/semantic_predicate_spec.rb +0 -175
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/sequence_spec.rb +0 -115
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/terminal_spec.rb +0 -81
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/terminal_symbol_spec.rb +0 -37
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/test_grammar.treetop +0 -7
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/test_grammar.tt +0 -7
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/test_grammar_do.treetop +0 -7
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/tt_compiler_spec.rb +0 -216
- data/lib/mail/vendor/treetop-1.4.4/spec/compiler/zero_or_more_spec.rb +0 -56
- data/lib/mail/vendor/treetop-1.4.4/spec/composition/a.treetop +0 -11
- data/lib/mail/vendor/treetop-1.4.4/spec/composition/b.treetop +0 -11
- data/lib/mail/vendor/treetop-1.4.4/spec/composition/c.treetop +0 -10
- data/lib/mail/vendor/treetop-1.4.4/spec/composition/d.treetop +0 -10
- data/lib/mail/vendor/treetop-1.4.4/spec/composition/f.treetop +0 -17
- data/lib/mail/vendor/treetop-1.4.4/spec/composition/grammar_composition_spec.rb +0 -40
- data/lib/mail/vendor/treetop-1.4.4/spec/composition/subfolder/e_includes_c.treetop +0 -15
- data/lib/mail/vendor/treetop-1.4.4/spec/ruby_extensions/string_spec.rb +0 -32
- data/lib/mail/vendor/treetop-1.4.4/spec/runtime/compiled_parser_spec.rb +0 -101
- data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/delete_spec.rb +0 -147
- data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/expire_range_spec.rb +0 -349
- data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/insert_and_delete_node.rb +0 -385
- data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/insert_spec.rb +0 -660
- data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/interval_skip_list_spec.graffle +0 -6175
- data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/interval_skip_list_spec.rb +0 -58
- data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/palindromic_fixture.rb +0 -23
- data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/palindromic_fixture_spec.rb +0 -163
- data/lib/mail/vendor/treetop-1.4.4/spec/runtime/interval_skip_list/spec_helper.rb +0 -84
- data/lib/mail/vendor/treetop-1.4.4/spec/runtime/syntax_node_spec.rb +0 -77
- data/lib/mail/vendor/treetop-1.4.4/spec/spec_helper.rb +0 -110
- data/lib/mail/vendor/treetop-1.4.4/treetop.gemspec +0 -18
- data/lib/mail/vendor/treetop.rb +0 -2
@@ -1,216 +0,0 @@
|
|
1
|
-
require 'digest/sha1'
|
2
|
-
|
3
|
-
# ensure the Kernel.system and Kernel.open's always use the correct tt and
|
4
|
-
# Treetop library versions, not a previously installed gem
|
5
|
-
ENV['PATH'] = File.expand_path(File.dirname(__FILE__) + '../../../bin' +
|
6
|
-
File::PATH_SEPARATOR + ENV['PATH'])
|
7
|
-
$LOAD_PATH.unshift(File.expand_path('../../../../lib', __FILE__))
|
8
|
-
|
9
|
-
describe "The 'tt' comand line compiler" do
|
10
|
-
|
11
|
-
context 'when processing a single grammar file' do
|
12
|
-
before(:each) do
|
13
|
-
# create a fresh but dumb grammar file for each example
|
14
|
-
@test_base = "dumb-#{rand(1000)}"
|
15
|
-
@test_grammar = "#{@test_base}.tt"
|
16
|
-
File.open(@test_grammar, 'w+') do |f|
|
17
|
-
f.print("grammar Dumb\n")
|
18
|
-
f.print("end\n")
|
19
|
-
end unless File.exists?(@test_grammar)
|
20
|
-
end
|
21
|
-
|
22
|
-
after(:each) do
|
23
|
-
# cleanup test grammar and parser output files
|
24
|
-
f = "#{@test_base}.rb"
|
25
|
-
File.delete(@test_grammar) if File.exists?(@test_grammar)
|
26
|
-
File.delete(f) if File.exists?(f)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'can compile a grammar file' do
|
30
|
-
# puts %q{emulate 'tt dumb.tt'}
|
31
|
-
system("ruby -S tt #{@test_grammar}").should be_true
|
32
|
-
|
33
|
-
pf = "#{@test_base}.rb"
|
34
|
-
File.exists?(pf).should be_true
|
35
|
-
File.zero?(pf).should_not be_true
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'can compile a relative pathed grammar file' do
|
39
|
-
dir = File.basename(File.expand_path(File.dirname(@test_grammar)))
|
40
|
-
|
41
|
-
# puts %q{emulate 'tt "../<current_dir>/dumb.tt"'}
|
42
|
-
system("ruby -S tt \"../#{dir}/#{@test_grammar}\"").should be_true
|
43
|
-
|
44
|
-
pf = "#{@test_base}.rb"
|
45
|
-
File.exists?(pf).should be_true
|
46
|
-
File.zero?(pf).should_not be_true
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'can compile an absolute pathed grammar file' do
|
50
|
-
# puts %q{emulate 'tt "/path/to/dumb.tt"'}
|
51
|
-
system("ruby -S tt \"#{File.expand_path(@test_grammar)}\"").should be_true
|
52
|
-
|
53
|
-
pf = "#{@test_base}.rb"
|
54
|
-
File.exists?(pf).should be_true
|
55
|
-
File.zero?(pf).should_not be_true
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'can compile without explicit file extensions' do
|
59
|
-
# puts %q{emulate 'tt dumb'}
|
60
|
-
system("ruby -S tt #{@test_base}").should be_true
|
61
|
-
|
62
|
-
pf = "#{@test_base}.rb"
|
63
|
-
File.exists?(pf).should be_true
|
64
|
-
File.zero?(pf).should_not be_true
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'skips nonexistent grammar file without failing or creating bogus output' do
|
68
|
-
# puts %q{emulate 'tt dumb.bad'}
|
69
|
-
Kernel.open("|ruby -S tt #{@test_base}.bad") do |io|
|
70
|
-
(io.read =~ /ERROR.*?not exist.*?continuing/).should_not be_nil
|
71
|
-
end
|
72
|
-
|
73
|
-
File.exists?("#{@test_base}.rb").should be_false
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'can compile to a specified parser source file' do
|
77
|
-
# puts %q{emulate 'tt -o my_dumb_test_parser.rb dumb'}
|
78
|
-
pf = 'my_dumb_test_parser.rb'
|
79
|
-
begin
|
80
|
-
system("ruby -S tt -o #{pf} #{@test_base}").should be_true
|
81
|
-
|
82
|
-
File.exists?(pf).should be_true
|
83
|
-
File.zero?(pf).should_not be_true
|
84
|
-
ensure
|
85
|
-
File.delete(pf) if File.exists?(pf)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'by default, does not overwrite an existing file without an autogenerated header' do
|
90
|
-
# puts %q{emulate 'tt -o must_save_parser.rb dumb'}
|
91
|
-
pf = 'must_save_parser.rb'
|
92
|
-
begin
|
93
|
-
system("ruby -S tt -o #{pf} #{@test_base}").should be_true
|
94
|
-
|
95
|
-
File.exists?(pf).should be_true
|
96
|
-
File.zero?(pf).should_not be_true
|
97
|
-
|
98
|
-
# Modify the file and make sure it remains unchanged:
|
99
|
-
File.open(pf, "r+") { |f| f.write("# Changed...") }
|
100
|
-
orig_file_hash = Digest::SHA1.hexdigest(File.read(pf))
|
101
|
-
|
102
|
-
Kernel.open("|ruby -S tt -o #{pf} #{@test_base}") do |io|
|
103
|
-
(io.read =~ /ERROR.*?already exists.*?skipping/).should_not be_nil
|
104
|
-
end
|
105
|
-
|
106
|
-
Digest::SHA1.hexdigest(File.read(pf)).should == orig_file_hash
|
107
|
-
ensure
|
108
|
-
File.delete(pf) if File.exists?(pf)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'by default, overwrites a changed file with an intact autogenerated header' do
|
113
|
-
# puts %q{emulate 'tt -o must_save_parser.rb dumb'}
|
114
|
-
pf = 'must_save_parser.rb'
|
115
|
-
begin
|
116
|
-
system("ruby -S tt -o #{pf} #{@test_base}").should be_true
|
117
|
-
|
118
|
-
File.exists?(pf).should be_true
|
119
|
-
File.zero?(pf).should_not be_true
|
120
|
-
orig_file_hash = Digest::SHA1.hexdigest(File.read(pf))
|
121
|
-
|
122
|
-
# Modify the file and make sure it gets reverted:
|
123
|
-
File.open(pf, "r+") { |f| f.gets; f.write("#") }
|
124
|
-
|
125
|
-
system("ruby -S tt -o #{pf} #{@test_base}").should be_true
|
126
|
-
Digest::SHA1.hexdigest(File.read(pf)).should == orig_file_hash
|
127
|
-
ensure
|
128
|
-
File.delete(pf) if File.exists?(pf)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'can be forced to overwrite existing file #{@test_base}' do
|
133
|
-
pf = "#{@test_base}.rb"
|
134
|
-
system("echo some junk >#{pf}").should be_true
|
135
|
-
|
136
|
-
File.exists?(pf).should be_true
|
137
|
-
File.zero?(pf).should_not be_true
|
138
|
-
orig_file_hash = Digest::SHA1.hexdigest(File.read(pf))
|
139
|
-
|
140
|
-
system("ruby -S tt -f #{@test_base}").should be_true
|
141
|
-
Digest::SHA1.hexdigest(File.read(pf)).should_not == orig_file_hash
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
|
146
|
-
context 'when processing multiple grammar files' do
|
147
|
-
|
148
|
-
before(:each) do
|
149
|
-
# provide fresh but dumb grammar files for each test
|
150
|
-
@test_bases = []
|
151
|
-
@test_grammars = []
|
152
|
-
|
153
|
-
%w[dumb1 dumb2].each do |e|
|
154
|
-
base = "#{e}-#{rand(1000)}"
|
155
|
-
grammar_file = "#{base}.tt"
|
156
|
-
@test_bases << base
|
157
|
-
@test_grammars << grammar_file
|
158
|
-
|
159
|
-
File.open(grammar_file, 'w+') do |f|
|
160
|
-
f.print("grammar #{e.capitalize}\n")
|
161
|
-
f.print("end\n")
|
162
|
-
end unless File.exists?(grammar_file)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
after(:each) do
|
167
|
-
# cleanup test grammar and output parser files
|
168
|
-
@test_grammars.each { |f| File.delete(f) if File.exists?(f) }
|
169
|
-
@test_bases.each { |f| File.delete("#{f}.rb") if File.exists?("#{f}.rb") }
|
170
|
-
end
|
171
|
-
|
172
|
-
it 'can compile them in one invocation' do
|
173
|
-
# puts %q{emulate 'tt dumb1.tt dumb2.tt'}
|
174
|
-
system("ruby -S tt #{@test_grammars.join(' ')}").should be_true
|
175
|
-
|
176
|
-
@test_bases.each do |f|
|
177
|
-
pf = "#{f}.rb"
|
178
|
-
File.exists?(pf).should be_true
|
179
|
-
File.zero?(pf).should_not be_true
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
it 'can compile them without explicit file extenstions' do
|
184
|
-
# puts %q{emulate 'tt dumb1 dumb2'}
|
185
|
-
system("ruby -S tt #{@test_bases.join(' ')}").should be_true
|
186
|
-
|
187
|
-
@test_bases.each do |f|
|
188
|
-
pf = "#{f}.rb"
|
189
|
-
File.exists?(pf).should be_true
|
190
|
-
File.zero?(pf).should_not be_true
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
it 'can skip nonexistent and invalid extension named grammar files' do
|
195
|
-
# puts %q{emulate 'tt not_here bad_ext.ttg dumb1 dumb2'}
|
196
|
-
system("ruby -S tt not_here bad_ext.ttg #{@test_bases.join(' ')} >/dev/null 2>&1").should be_true
|
197
|
-
|
198
|
-
File.exists?('not_here.rb').should_not be_true
|
199
|
-
File.exists?('bad_ext.rb').should_not be_true
|
200
|
-
|
201
|
-
@test_bases.each do |f|
|
202
|
-
pf = "#{f}.rb"
|
203
|
-
File.exists?(pf).should be_true
|
204
|
-
File.zero?(pf).should_not be_true
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
it 'can not specify an output file' do
|
209
|
-
# puts %q{emulate 'tt -o my_bogus_test_parser.rb dumb1 dumb2'}
|
210
|
-
pf = 'my_bogus_test_parser.rb'
|
211
|
-
system("ruby -S tt -o #{pf} #{@test_bases.join(' ')} >/dev/null 2>&1").should be_false
|
212
|
-
File.exists?(pf).should be_false
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module ZeroOrMoreSpec
|
4
|
-
class Foo < Treetop::Runtime::SyntaxNode
|
5
|
-
end
|
6
|
-
|
7
|
-
describe "zero or more of a terminal symbol followed by a node class declaration and a block" do
|
8
|
-
testing_expression '"foo"* <ZeroOrMoreSpec::Foo> { def a_method; end }'
|
9
|
-
|
10
|
-
it "successfully parses epsilon, returning an instance declared node class and recording a terminal failure" do
|
11
|
-
parse('') do |result|
|
12
|
-
result.should_not be_nil
|
13
|
-
result.should be_an_instance_of(Foo)
|
14
|
-
result.should respond_to(:a_method)
|
15
|
-
|
16
|
-
terminal_failures = parser.terminal_failures
|
17
|
-
terminal_failures.size.should == 1
|
18
|
-
failure = terminal_failures.first
|
19
|
-
failure.index.should == 0
|
20
|
-
failure.expected_string.should == 'foo'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
it "successfully parses two of that terminal in a row, returning an instance of the declared node class and recording a failure representing the third attempt " do
|
25
|
-
parse("foofoo") do |result|
|
26
|
-
result.should_not be_nil
|
27
|
-
result.should be_an_instance_of(Foo)
|
28
|
-
|
29
|
-
terminal_failures = parser.terminal_failures
|
30
|
-
terminal_failures.size.should == 1
|
31
|
-
failure = terminal_failures.first
|
32
|
-
failure.index.should == 6
|
33
|
-
failure.expected_string.should == 'foo'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "Zero or more of a sequence" do
|
39
|
-
testing_expression '("foo" "bar")*'
|
40
|
-
|
41
|
-
it "resets the index appropriately following partially matcing input" do
|
42
|
-
parse('foobarfoo', :consume_all_input => false) do |result|
|
43
|
-
result.should_not be_nil
|
44
|
-
result.interval.should == (0...6)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "Zero or more of a choice" do
|
50
|
-
testing_expression '("a" / "b")*'
|
51
|
-
|
52
|
-
it "successfully parses matching input" do
|
53
|
-
parse('abba').should_not be_nil
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module GrammarCompositionSpec
|
4
|
-
describe "several composed grammars" do
|
5
|
-
before do
|
6
|
-
dir = File.dirname(__FILE__)
|
7
|
-
Treetop.load File.join(dir, 'a')
|
8
|
-
Treetop.load File.join(dir, 'b')
|
9
|
-
Treetop.load File.join(dir, 'c')
|
10
|
-
# Check that polyglot finds d.treetop and loads it:
|
11
|
-
$: << dir
|
12
|
-
require 'd'
|
13
|
-
|
14
|
-
@c = ::Test::CParser.new
|
15
|
-
@d = ::Test::DParser.new
|
16
|
-
end
|
17
|
-
|
18
|
-
specify "rules in C have access to rules defined in A and B" do
|
19
|
-
@c.parse('abc').should_not be_nil
|
20
|
-
end
|
21
|
-
|
22
|
-
specify "rules in C can override rules in A and B with super semantics" do
|
23
|
-
@d.parse('superkeywordworks').should_not be_nil
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "composed grammar chaining with require" do
|
28
|
-
before do
|
29
|
-
# Load f with polyglot without using the load path:
|
30
|
-
require File.dirname(__FILE__) + '/f'
|
31
|
-
|
32
|
-
@f = ::Test::FParser.new
|
33
|
-
end
|
34
|
-
|
35
|
-
specify "rules in F have access to rule defined in E" do
|
36
|
-
@f.parse('abcef').should_not be_nil
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe String do
|
4
|
-
before do
|
5
|
-
@string = %{
|
6
|
-
0123456789
|
7
|
-
012345
|
8
|
-
01234567
|
9
|
-
0123
|
10
|
-
}.tabto(0).strip
|
11
|
-
end
|
12
|
-
|
13
|
-
it "can translate indices to column numbers" do
|
14
|
-
@string.column_of(0).should == 1
|
15
|
-
@string.column_of(5).should == 6
|
16
|
-
@string.column_of(10).should == 11
|
17
|
-
@string.column_of(11).should == 1
|
18
|
-
@string.column_of(17).should == 7
|
19
|
-
@string.column_of(18).should == 1
|
20
|
-
@string.column_of(24).should == 7
|
21
|
-
end
|
22
|
-
|
23
|
-
it "can translate indices to line numbers" do
|
24
|
-
@string.line_of(0).should == 1
|
25
|
-
@string.line_of(5).should == 1
|
26
|
-
@string.line_of(10).should == 1
|
27
|
-
@string.line_of(11).should == 2
|
28
|
-
@string.line_of(17).should == 2
|
29
|
-
@string.line_of(18).should == 3
|
30
|
-
@string.line_of(24).should == 3
|
31
|
-
end
|
32
|
-
end
|