livetext 0.9.13 → 0.9.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/errors.rb +4 -2
- data/lib/functions.rb +1 -1
- data/lib/helpers.rb +4 -0
- data/lib/livetext.rb +15 -9
- data/lib/parser/general.rb +1 -1
- data/lib/parser/mixin.rb +1 -7
- data/lib/processor.rb +1 -8
- data/lib/standard.rb +6 -11
- data/lib/userapi.rb +0 -4
- data/test/all.rb +1 -0
- data/test/formatting-tests.rb +35 -0
- data/test/snapshots/OMIT.txt +10 -0
- data/test/snapshots/error_inc_line_num/match-error.txt +1 -0
- data/test/snapshots/error_invalid_name/match-error.txt +1 -0
- data/test/snapshots/error_line_num/match-error.txt +1 -0
- data/test/snapshots/error_mismatched_end/expected-output.txt +0 -2
- data/test/snapshots/error_mismatched_end/match-error.txt +1 -0
- data/test/snapshots/error_missing_end/match-error.txt +1 -0
- data/test/snapshots/error_no_such_copy/match-error.txt +1 -0
- data/test/snapshots/error_no_such_inc/match-error.txt +1 -0
- data/test/snapshots/error_no_such_mixin/match-error.txt +1 -0
- data/test/snapshots/{lines.txt → formatting-tests.txt} +0 -0
- data/test/snapshots/predef_vars/match-output.txt +6 -0
- data/test/snapshots.rb +41 -92
- data/test/unit/parser/general.rb +21 -21
- data/test/unit/parser/mixin.rb +1 -1
- data/test/unit/parser.rb +2 -0
- metadata +13 -44
- data/test/snapshots/error_inc_line_num/actual-error.txt +0 -1
- data/test/snapshots/error_inc_line_num/actual-output.txt +0 -13
- data/test/snapshots/error_inc_line_num/expected-err-line1match.txt +0 -1
- data/test/snapshots/error_inc_line_num/out-sdiff.txt +0 -14
- data/test/snapshots/error_invalid_name/actual-error.txt +0 -10
- data/test/snapshots/error_invalid_name/actual-output.txt +0 -0
- data/test/snapshots/error_invalid_name/expected-err-line1match.txt +0 -1
- data/test/snapshots/error_invalid_name/out-sdiff.txt +0 -6
- data/test/snapshots/error_line_num/actual-error.txt +0 -1
- data/test/snapshots/error_line_num/actual-output.txt +0 -5
- data/test/snapshots/error_line_num/expected-err-line1match.txt +0 -1
- data/test/snapshots/error_line_num/out-sdiff.txt +0 -6
- data/test/snapshots/error_mismatched_end/actual-error.txt +0 -1
- data/test/snapshots/error_mismatched_end/actual-output.txt +0 -8
- data/test/snapshots/error_mismatched_end/expected-err-line1match.txt +0 -1
- data/test/snapshots/error_mismatched_end/out-sdiff.txt +0 -9
- data/test/snapshots/error_missing_end/actual-error.txt +0 -1
- data/test/snapshots/error_missing_end/actual-output.txt +0 -5
- data/test/snapshots/error_missing_end/expected-err-line1match.txt +0 -1
- data/test/snapshots/error_missing_end/out-sdiff.txt +0 -6
- data/test/snapshots/error_name_not_permitted/OLD-exp-out +0 -4
- data/test/snapshots/error_no_such_copy/actual-error.txt +0 -10
- data/test/snapshots/error_no_such_copy/actual-output.txt +0 -0
- data/test/snapshots/error_no_such_copy/expected-err-line1match.txt +0 -1
- data/test/snapshots/error_no_such_copy/out-sdiff.txt +0 -5
- data/test/snapshots/error_no_such_inc/actual-error.txt +0 -10
- data/test/snapshots/error_no_such_inc/actual-output.txt +0 -0
- data/test/snapshots/error_no_such_inc/expected-err-line1match.txt +0 -1
- data/test/snapshots/error_no_such_inc/out-sdiff.txt +0 -6
- data/test/snapshots/error_no_such_mixin/actual-error.txt +0 -1
- data/test/snapshots/error_no_such_mixin/actual-output.txt +0 -11
- data/test/snapshots/error_no_such_mixin/expected-err-line1match.txt +0 -1
- data/test/snapshots/error_no_such_mixin/out-sdiff.txt +0 -12
- data/test/snapshots/predef_vars/actual-error.txt +0 -0
- data/test/snapshots/predef_vars/actual-output.txt +0 -6
- data/test/snapshots/predef_vars/expected-output.txt +0 -6
- data/test/snapshots/predef_vars/out-sdiff.txt +0 -7
- data/test/snapshots/simple_mixin/actual-error.txt +0 -2
- data/test/snapshots/simple_mixin/actual-output.txt +0 -4
- data/test/snapshots/simple_mixin/out-sdiff.txt +0 -6
- data/test/unit/parse_misc.rb +0 -60
- data/test/unit/parse_set.rb +0 -157
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: livetext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
@@ -47,10 +47,12 @@ files:
|
|
47
47
|
- test/affirm/lm-kbks.lt
|
48
48
|
- test/all.rb
|
49
49
|
- test/cleanup
|
50
|
+
- test/formatting-tests.rb
|
50
51
|
- test/formatting.rb
|
51
52
|
- test/newtest
|
52
53
|
- test/sdtest
|
53
54
|
- test/snapshots.rb
|
55
|
+
- test/snapshots/OMIT.txt
|
54
56
|
- test/snapshots/basic_formatting/expected-error.txt
|
55
57
|
- test/snapshots/basic_formatting/expected-output.txt
|
56
58
|
- test/snapshots/basic_formatting/source.lt3
|
@@ -68,58 +70,33 @@ files:
|
|
68
70
|
- test/snapshots/def_method/expected-error.txt
|
69
71
|
- test/snapshots/def_method/expected-output.txt
|
70
72
|
- test/snapshots/def_method/source.lt3
|
71
|
-
- test/snapshots/error_inc_line_num/actual-error.txt
|
72
|
-
- test/snapshots/error_inc_line_num/actual-output.txt
|
73
|
-
- test/snapshots/error_inc_line_num/expected-err-line1match.txt
|
74
73
|
- test/snapshots/error_inc_line_num/expected-output.txt
|
75
74
|
- test/snapshots/error_inc_line_num/file2.lt3
|
76
|
-
- test/snapshots/error_inc_line_num/
|
75
|
+
- test/snapshots/error_inc_line_num/match-error.txt
|
77
76
|
- test/snapshots/error_inc_line_num/source.lt3
|
78
|
-
- test/snapshots/error_invalid_name/actual-error.txt
|
79
|
-
- test/snapshots/error_invalid_name/actual-output.txt
|
80
|
-
- test/snapshots/error_invalid_name/expected-err-line1match.txt
|
81
77
|
- test/snapshots/error_invalid_name/expected-output.txt
|
82
|
-
- test/snapshots/error_invalid_name/
|
78
|
+
- test/snapshots/error_invalid_name/match-error.txt
|
83
79
|
- test/snapshots/error_invalid_name/source.lt3
|
84
|
-
- test/snapshots/error_line_num/actual-error.txt
|
85
|
-
- test/snapshots/error_line_num/actual-output.txt
|
86
|
-
- test/snapshots/error_line_num/expected-err-line1match.txt
|
87
80
|
- test/snapshots/error_line_num/expected-output.txt
|
88
|
-
- test/snapshots/error_line_num/
|
81
|
+
- test/snapshots/error_line_num/match-error.txt
|
89
82
|
- test/snapshots/error_line_num/source.lt3
|
90
|
-
- test/snapshots/error_mismatched_end/actual-error.txt
|
91
|
-
- test/snapshots/error_mismatched_end/actual-output.txt
|
92
|
-
- test/snapshots/error_mismatched_end/expected-err-line1match.txt
|
93
83
|
- test/snapshots/error_mismatched_end/expected-output.txt
|
94
|
-
- test/snapshots/error_mismatched_end/
|
84
|
+
- test/snapshots/error_mismatched_end/match-error.txt
|
95
85
|
- test/snapshots/error_mismatched_end/source.lt3
|
96
|
-
- test/snapshots/error_missing_end/actual-error.txt
|
97
|
-
- test/snapshots/error_missing_end/actual-output.txt
|
98
|
-
- test/snapshots/error_missing_end/expected-err-line1match.txt
|
99
86
|
- test/snapshots/error_missing_end/expected-output.txt
|
100
|
-
- test/snapshots/error_missing_end/
|
87
|
+
- test/snapshots/error_missing_end/match-error.txt
|
101
88
|
- test/snapshots/error_missing_end/source.lt3
|
102
|
-
- test/snapshots/error_name_not_permitted/OLD-exp-out
|
103
89
|
- test/snapshots/error_name_not_permitted/expected-output.txt
|
104
90
|
- test/snapshots/error_name_not_permitted/match-error.txt
|
105
91
|
- test/snapshots/error_name_not_permitted/source.lt3
|
106
|
-
- test/snapshots/error_no_such_copy/actual-error.txt
|
107
|
-
- test/snapshots/error_no_such_copy/actual-output.txt
|
108
|
-
- test/snapshots/error_no_such_copy/expected-err-line1match.txt
|
109
92
|
- test/snapshots/error_no_such_copy/expected-output.txt
|
110
|
-
- test/snapshots/error_no_such_copy/
|
93
|
+
- test/snapshots/error_no_such_copy/match-error.txt
|
111
94
|
- test/snapshots/error_no_such_copy/source.lt3
|
112
|
-
- test/snapshots/error_no_such_inc/actual-error.txt
|
113
|
-
- test/snapshots/error_no_such_inc/actual-output.txt
|
114
|
-
- test/snapshots/error_no_such_inc/expected-err-line1match.txt
|
115
95
|
- test/snapshots/error_no_such_inc/expected-output.txt
|
116
|
-
- test/snapshots/error_no_such_inc/
|
96
|
+
- test/snapshots/error_no_such_inc/match-error.txt
|
117
97
|
- test/snapshots/error_no_such_inc/source.lt3
|
118
|
-
- test/snapshots/error_no_such_mixin/actual-error.txt
|
119
|
-
- test/snapshots/error_no_such_mixin/actual-output.txt
|
120
|
-
- test/snapshots/error_no_such_mixin/expected-err-line1match.txt
|
121
98
|
- test/snapshots/error_no_such_mixin/expected-output.txt
|
122
|
-
- test/snapshots/error_no_such_mixin/
|
99
|
+
- test/snapshots/error_no_such_mixin/match-error.txt
|
123
100
|
- test/snapshots/error_no_such_mixin/source.lt3
|
124
101
|
- test/snapshots/example_alpha/expected-error.txt
|
125
102
|
- test/snapshots/example_alpha/expected-output.txt
|
@@ -128,21 +105,18 @@ files:
|
|
128
105
|
- test/snapshots/example_alpha2/expected-output.txt
|
129
106
|
- test/snapshots/example_alpha2/source.lt3
|
130
107
|
- test/snapshots/fixit
|
108
|
+
- test/snapshots/formatting-tests.txt
|
131
109
|
- test/snapshots/functions/expected-error.txt
|
132
110
|
- test/snapshots/functions/expected-output.txt
|
133
111
|
- test/snapshots/functions/source.lt3
|
134
112
|
- test/snapshots/hello_world/expected-error.txt
|
135
113
|
- test/snapshots/hello_world/expected-output.txt
|
136
114
|
- test/snapshots/hello_world/source.lt3
|
137
|
-
- test/snapshots/lines.txt
|
138
115
|
- test/snapshots/more_complex_vars/expected-error.txt
|
139
116
|
- test/snapshots/more_complex_vars/expected-output.txt
|
140
117
|
- test/snapshots/more_complex_vars/source.lt3
|
141
|
-
- test/snapshots/predef_vars/actual-error.txt
|
142
|
-
- test/snapshots/predef_vars/actual-output.txt
|
143
118
|
- test/snapshots/predef_vars/expected-error.txt
|
144
|
-
- test/snapshots/predef_vars/
|
145
|
-
- test/snapshots/predef_vars/out-sdiff.txt
|
119
|
+
- test/snapshots/predef_vars/match-output.txt
|
146
120
|
- test/snapshots/predef_vars/source.lt3
|
147
121
|
- test/snapshots/raw_lines/expected-error.txt
|
148
122
|
- test/snapshots/raw_lines/expected-output.txt
|
@@ -159,11 +133,8 @@ files:
|
|
159
133
|
- test/snapshots/simple_include/expected-output.txt
|
160
134
|
- test/snapshots/simple_include/simplefile.inc
|
161
135
|
- test/snapshots/simple_include/source.lt3
|
162
|
-
- test/snapshots/simple_mixin/actual-error.txt
|
163
|
-
- test/snapshots/simple_mixin/actual-output.txt
|
164
136
|
- test/snapshots/simple_mixin/expected-error.txt
|
165
137
|
- test/snapshots/simple_mixin/expected-output.txt
|
166
|
-
- test/snapshots/simple_mixin/out-sdiff.txt
|
167
138
|
- test/snapshots/simple_mixin/simple_mixin.rb
|
168
139
|
- test/snapshots/simple_mixin/source.lt3
|
169
140
|
- test/snapshots/simple_vars/expected-error.txt
|
@@ -179,8 +150,6 @@ files:
|
|
179
150
|
- test/testlines.rb
|
180
151
|
- test/unit/all.rb
|
181
152
|
- test/unit/html.rb
|
182
|
-
- test/unit/parse_misc.rb
|
183
|
-
- test/unit/parse_set.rb
|
184
153
|
- test/unit/parser.rb
|
185
154
|
- test/unit/parser/all.rb
|
186
155
|
- test/unit/parser/general.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Name 'foobar' is unknown
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Name 'foobar' is unknown
|
@@ -1,14 +0,0 @@
|
|
1
|
-
EXPECTED | ACTUAL
|
2
|
-
This is my This is my
|
3
|
-
source file source file
|
4
|
-
which includes file2 here: which includes file2 here:
|
5
|
-
This is file2 This is file2
|
6
|
-
which has an error which has an error
|
7
|
-
about an unknown command about an unknown command
|
8
|
-
in line 5 in line 5
|
9
|
-
<p> <p>
|
10
|
-
|
11
|
-
And this is file2 line 7. And this is file2 line 7.
|
12
|
-
And here we are And here we are
|
13
|
-
back in the back in the
|
14
|
-
original file. original file.
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:7:in `check_disallowed': to_s (DisallowedName)
|
2
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/standard.rb:142:in `_def'
|
3
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:232:in `handle_dotcmd'
|
4
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:141:in `process_line'
|
5
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:203:in `block in process_file'
|
6
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:200:in `loop'
|
7
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:200:in `process_file'
|
8
|
-
from ../../../bin/livetext:88:in `block in <main>'
|
9
|
-
from ../../../bin/livetext:57:in `loop'
|
10
|
-
from ../../../bin/livetext:57:in `<main>'
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Illegal name 'to_s'
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Name 'foobar' is unknown
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Name 'foobar' is unknown
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Name 'end' is unknown
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: Mismatched 'end'
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: #<RuntimeError: Expected .end, found end of file>
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: #<RuntimeError: Expected .end, found end of file>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:11:in `check_file_exists': Error: file nosuchfile.txt not found (FileNotFound)
|
2
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/standard.rb:280:in `copy'
|
3
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:232:in `handle_dotcmd'
|
4
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:141:in `process_line'
|
5
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:203:in `block in process_file'
|
6
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:200:in `loop'
|
7
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:200:in `process_file'
|
8
|
-
from ../../../bin/livetext:88:in `block in <main>'
|
9
|
-
from ../../../bin/livetext:57:in `loop'
|
10
|
-
from ../../../bin/livetext:57:in `<main>'
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: file nosuchfile.txt not found
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/Users/Hal/Dropbox/topx/git/livetext/lib/helpers.rb:11:in `check_file_exists': Error: file nosuchinc.lt3 not found (FileNotFound)
|
2
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/standard.rb:237:in `_include'
|
3
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:232:in `handle_dotcmd'
|
4
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:141:in `process_line'
|
5
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:203:in `block in process_file'
|
6
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:200:in `loop'
|
7
|
-
from /Users/Hal/Dropbox/topx/git/livetext/lib/livetext.rb:200:in `process_file'
|
8
|
-
from ../../../bin/livetext:88:in `block in <main>'
|
9
|
-
from ../../../bin/livetext:57:in `loop'
|
10
|
-
from ../../../bin/livetext:57:in `<main>'
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: file nosuchinc.lt3 not found
|
@@ -1 +0,0 @@
|
|
1
|
-
Error: #<ArgumentError: wrong number of arguments (given 1, expected 0)>
|
@@ -1 +0,0 @@
|
|
1
|
-
No such mixin 'nosuchthing'
|
File without changes
|
@@ -1,7 +0,0 @@
|
|
1
|
-
EXPECTED | ACTUAL
|
2
|
-
Here we go... Here we go...
|
3
|
-
File = source.lt3 File = source.lt3
|
4
|
-
FileDir = /Users/Hal/Dropbox/topx/git/livetext/test/snapsho FileDir = /Users/Hal/Dropbox/topx/git/livetext/test/snapsho
|
5
|
-
User = Hal User = Hal
|
6
|
-
Version = 0.9.12 | Version = 0.9.11
|
7
|
-
NoSuchVar = [NoSuchVar is undefined] NoSuchVar = [NoSuchVar is undefined]
|
data/test/unit/parse_misc.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
|
3
|
-
# FIXME delete??
|
4
|
-
|
5
|
-
require 'parse_misc'
|
6
|
-
|
7
|
-
ParseMisc = ::Livetext::ParseMisc
|
8
|
-
|
9
|
-
class TestParseMisc < MiniTest::Test
|
10
|
-
|
11
|
-
def setup
|
12
|
-
end
|
13
|
-
|
14
|
-
def teardown
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_strip_quotes
|
18
|
-
assert_raises(NilValue) { ParseMisc.new(nil).strip_quotes }
|
19
|
-
assert_raises(NullString) { ParseMisc.new("").strip_quotes }
|
20
|
-
assert_raises(MismatchedQuotes) { ParseMisc.new(%['test]).strip_quotes }
|
21
|
-
# assert_raises(MismatchedQuotes) { ParseMisc.new(%[test']).strip_quotes }
|
22
|
-
assert_raises(MismatchedQuotes) { ParseMisc.new(%["test]).strip_quotes }
|
23
|
-
# assert_raises(MismatchedQuotes) { ParseMisc.new(%[test"]).strip_quotes }
|
24
|
-
assert_raises(MismatchedQuotes) { ParseMisc.new(%["test']).strip_quotes }
|
25
|
-
assert_raises(MismatchedQuotes) { ParseMisc.new(%['test"]).strip_quotes }
|
26
|
-
|
27
|
-
assert ParseMisc.new(%[24601]).strip_quotes == "24601", "Failure 1"
|
28
|
-
assert ParseMisc.new(%[3.14]).strip_quotes == "3.14", "Failure 2"
|
29
|
-
assert ParseMisc.new(%[test]).strip_quotes == "test", "Failure 3"
|
30
|
-
assert ParseMisc.new(%['test']).strip_quotes == "test", "Failure 4"
|
31
|
-
assert ParseMisc.new(%["test"]).strip_quotes == "test", "Failure 5"
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_variables
|
35
|
-
vars = ["foo 234\n", "bar 456\n"]
|
36
|
-
expect = [%w[foo 234], %w[bar 456]]
|
37
|
-
assert_equal ParseMisc.parse_vars(vars), expect
|
38
|
-
|
39
|
-
vars = ["foo2 234", "bar2 456"] # newline irrelevant
|
40
|
-
expect = [%w[foo2 234], %w[bar2 456]]
|
41
|
-
assert_equal ParseMisc.parse_vars(vars), expect
|
42
|
-
|
43
|
-
# quotes are not stripped... hmm
|
44
|
-
vars = ["alpha 'simple string'", 'beta "another string"']
|
45
|
-
expect = [["alpha", "'simple string'"], ["beta", '"another string"']]
|
46
|
-
assert_equal ParseMisc.parse_vars(vars), expect
|
47
|
-
|
48
|
-
# prefix (namespacing)
|
49
|
-
vars = ["alpha 'simple string'", 'beta "another string"']
|
50
|
-
expect = [["this.alpha", "'simple string'"], ["this.beta", '"another string"']]
|
51
|
-
assert_equal ParseMisc.parse_vars(vars, prefix: "this"), expect
|
52
|
-
|
53
|
-
# prefix (namespacing)
|
54
|
-
vars = ["alpha 'simple string'", 'beta "another string"']
|
55
|
-
expect = [["this.that.alpha", "'simple string'"], ["this.that.beta", '"another string"']]
|
56
|
-
assert_equal ParseMisc.parse_vars(vars, prefix: "this.that"), expect
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
data/test/unit/parse_set.rb
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'minitest/autorun'
|
3
|
-
|
4
|
-
require_relative '../../lib/parse/set'
|
5
|
-
|
6
|
-
ParseSet = Livetext::ParseSet
|
7
|
-
|
8
|
-
class TestParseSet < MiniTest::Test
|
9
|
-
|
10
|
-
def setup
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_one_unquoted
|
17
|
-
set = ParseSet.new('my_var_123 = 789').parse
|
18
|
-
pair = set.first
|
19
|
-
assert_equal pair, %w[my_var_123 789]
|
20
|
-
|
21
|
-
set = ParseSet.new('var_234 = naked_string').parse
|
22
|
-
pair = set.first
|
23
|
-
assert_equal pair, %w[var_234 naked_string]
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_one_single_quoted
|
27
|
-
set = ParseSet.new("fancy.var.name = 'simple string'").parse
|
28
|
-
pair = set.first
|
29
|
-
assert_equal pair, ["fancy.var.name", "simple string"]
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_one_double_quoted
|
33
|
-
set = ParseSet.new('fancy.var2 = "another string"').parse
|
34
|
-
pair = set.first
|
35
|
-
assert_equal pair, ["fancy.var2", "another string"]
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_multiple_unquoted
|
39
|
-
pair1, pair2 = ParseSet.new("this=345, that=678").parse
|
40
|
-
assert_equal pair1, %w[this 345]
|
41
|
-
assert_equal pair2, %w[that 678]
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_multiple_unquoted_quoted
|
45
|
-
pair1, pair2 = ParseSet.new('alpha = 567, beta = "oh well"').parse
|
46
|
-
assert_equal pair1, %w[alpha 567]
|
47
|
-
assert_equal pair2, ["beta", "oh well"]
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_quote_embedded_comma
|
51
|
-
set = ParseSet.new('gamma = "oh, well"').parse
|
52
|
-
pair = set.first
|
53
|
-
assert_equal pair, ["gamma", "oh, well"]
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_get_var
|
57
|
-
@parse = ParseSet.new("foo=345")
|
58
|
-
assert_equal @parse.get_var, "foo"
|
59
|
-
@parse = ParseSet.new("foo = 345")
|
60
|
-
assert_equal @parse.get_var, "foo"
|
61
|
-
@parse = ParseSet.new("foo123 = 345")
|
62
|
-
assert_equal @parse.get_var, "foo123"
|
63
|
-
@parse = ParseSet.new("foo_bar = 345")
|
64
|
-
assert_equal @parse.get_var, "foo_bar"
|
65
|
-
@parse = ParseSet.new("Foobar = 345")
|
66
|
-
assert_equal @parse.get_var, "Foobar"
|
67
|
-
@parse = ParseSet.new("_foobar = 345")
|
68
|
-
assert_equal @parse.get_var, "_foobar"
|
69
|
-
|
70
|
-
# will not notice missing equal sign till later parsing
|
71
|
-
@parse = ParseSet.new("foo bar")
|
72
|
-
assert_equal @parse.get_var, "foo"
|
73
|
-
|
74
|
-
# can detect missing equal sign if iteration ends
|
75
|
-
@parse = ParseSet.new("foo")
|
76
|
-
assert_raises(NoEqualSign) { @parse.get_var }
|
77
|
-
@parse = ParseSet.new("foo-bar = 345")
|
78
|
-
assert_raises(BadVariableName) { @parse.get_var }
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_skip_equal
|
82
|
-
@parse = ParseSet.new("=")
|
83
|
-
assert_nil @parse.skip_equal
|
84
|
-
@parse = ParseSet.new(" = ")
|
85
|
-
assert_nil @parse.skip_equal
|
86
|
-
@parse = ParseSet.new(" =")
|
87
|
-
assert_nil @parse.skip_equal
|
88
|
-
@parse = ParseSet.new(" = 345")
|
89
|
-
assert_equal @parse.skip_equal, "3"
|
90
|
-
@parse = ParseSet.new(" = 'meh'")
|
91
|
-
assert_equal @parse.skip_equal, "'"
|
92
|
-
|
93
|
-
@parse = ParseSet.new("no equal here")
|
94
|
-
assert_raises(NoEqualSign) { @parse.skip_equal }
|
95
|
-
@parse = ParseSet.new("")
|
96
|
-
assert_raises(NoEqualSign) { @parse.skip_equal }
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_quoted_value
|
100
|
-
@parse = ParseSet.new(%['this'])
|
101
|
-
assert_equal @parse.quoted_value, "this"
|
102
|
-
@parse = ParseSet.new(%["that"])
|
103
|
-
assert_equal @parse.quoted_value, "that"
|
104
|
-
@parse = ParseSet.new(%[""])
|
105
|
-
assert_equal @parse.quoted_value, ""
|
106
|
-
@parse = ParseSet.new(%[''])
|
107
|
-
assert_equal @parse.quoted_value, ""
|
108
|
-
|
109
|
-
@parse = ParseSet.new(%['foo"])
|
110
|
-
assert_raises(BadQuotedString) { @parse.quoted_value }
|
111
|
-
@parse = ParseSet.new(%["bar'])
|
112
|
-
assert_raises(BadQuotedString) { @parse.quoted_value }
|
113
|
-
@parse = ParseSet.new(%['baz])
|
114
|
-
assert_raises(BadQuotedString) { @parse.quoted_value }
|
115
|
-
@parse = ParseSet.new(%["bam])
|
116
|
-
assert_raises(BadQuotedString) { @parse.quoted_value }
|
117
|
-
# LATER:
|
118
|
-
# - allow (escaped?) comma in quoted string
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_unquoted_value
|
122
|
-
# Note: an unquoted value is still a string!
|
123
|
-
@parse = ParseSet.new(%[342 ])
|
124
|
-
assert_equal @parse.unquoted_value, "342"
|
125
|
-
@parse = ParseSet.new(%[343,])
|
126
|
-
assert_equal @parse.unquoted_value, "343"
|
127
|
-
@parse = ParseSet.new(%[344,678])
|
128
|
-
assert_equal @parse.unquoted_value, "344"
|
129
|
-
@parse = ParseSet.new(%[345.123])
|
130
|
-
assert_equal @parse.unquoted_value, "345.123"
|
131
|
-
@parse = ParseSet.new(%[whatever])
|
132
|
-
assert_equal @parse.unquoted_value, "whatever"
|
133
|
-
|
134
|
-
# LATER:
|
135
|
-
# - disallow comma in unquoted string
|
136
|
-
# - disallow quote trailing unquoted string
|
137
|
-
# - allow/disallow escaping??
|
138
|
-
end
|
139
|
-
|
140
|
-
# BUG: FormatLine doesn't know variables in this context!
|
141
|
-
|
142
|
-
def xtest_4
|
143
|
-
set = ParseSet.new("file = $File").parse
|
144
|
-
assert_equal set.first, "file"
|
145
|
-
assert set.last !~ /undefined/
|
146
|
-
end
|
147
|
-
|
148
|
-
# BUG: ...or functions.
|
149
|
-
# (Additional bug: Failing silently seems wrong.)
|
150
|
-
|
151
|
-
def xtest_5
|
152
|
-
set = ParseSet.new("date = $$date").parse
|
153
|
-
assert_equal set.first, "date"
|
154
|
-
assert set.last =~ /^\d\d.\d\d.\d\d/
|
155
|
-
end
|
156
|
-
|
157
|
-
end
|