livetext 0.9.13 → 0.9.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.lt3 +2 -2
- data/imports/bookish.rb +288 -0
- data/imports/calibre.rb +28 -0
- data/imports/livemagick.rb +133 -0
- data/imports/markdown.rb +44 -0
- data/imports/markdown_importable.rb +46 -0
- data/imports/pyggish.rb +204 -0
- data/imports/tutorial.rb +95 -0
- data/lib/cmdargs.rb +93 -0
- data/lib/errors.rb +4 -2
- data/lib/formatline.rb +56 -83
- data/lib/functions.rb +1 -1
- data/lib/handler/icanhaz.rb +35 -0
- data/lib/handler.rb +1 -0
- data/lib/helpers.rb +177 -4
- data/lib/livetext.rb +20 -139
- data/lib/parser/file.rb +8 -0
- data/lib/parser/general.rb +1 -1
- data/lib/parser/import.rb +1 -3
- data/lib/parser/mixin.rb +22 -30
- data/lib/parser/set.rb +35 -26
- data/lib/parser/string.rb +19 -4
- data/lib/processor.rb +2 -12
- data/lib/standard.rb +73 -107
- data/lib/userapi.rb +1 -4
- data/livetext.gemspec +2 -1
- data/plugin/bookish.rb +26 -22
- data/plugin/calibre.rb +1 -1
- data/plugin/livemagick.rb +10 -10
- data/plugin/markdown.rb +13 -11
- data/plugin/pyggish.rb +94 -84
- data/plugin/tutorial.rb +10 -5
- data/test/snapshots/OMIT.txt +11 -0
- data/test/snapshots/clusion.txt +84 -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_copy/source.lt3 +0 -1
- 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/icanhaz/expected-output.txt +5 -0
- data/test/snapshots/icanhaz/match-error.txt +1 -0
- data/test/snapshots/icanhaz/simple_import.rb +5 -0
- data/test/snapshots/{error_no_such_mixin/actual-output.txt → icanhaz/source.lt3} +3 -4
- data/test/snapshots/{error_invalid_name/actual-output.txt → icanhaz2/expected-error.txt} +0 -0
- data/test/snapshots/icanhaz2/expected-output.txt +6 -0
- data/test/snapshots/icanhaz2/simple_canhaz.rb +5 -0
- data/test/snapshots/icanhaz2/source.lt3 +6 -0
- data/test/snapshots/predef_vars/match-output.txt +6 -0
- data/test/snapshots/{error_no_such_copy/actual-output.txt → simple_import/expected-error.txt} +0 -0
- data/test/snapshots/simple_import/expected-output.txt +7 -0
- data/test/snapshots/simple_import/simple_import.rb +5 -0
- data/test/snapshots/simple_import/source.lt3 +7 -0
- data/test/snapshots/simple_include/source.lt3 +0 -1
- data/test/snapshots.rb +103 -107
- data/test/unit/all.rb +1 -0
- data/test/unit/formatline.rb +650 -0
- data/test/unit/parser/general.rb +21 -21
- data/test/unit/parser/importable.rb +1 -1
- data/test/unit/parser/mixin.rb +2 -2
- data/test/unit/parser/set.rb +19 -12
- data/test/unit/parser/string.rb +14 -14
- data/test/unit/parser.rb +2 -0
- metadata +37 -46
- data/test/formatting.rb +0 -103
- 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/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/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/expected-err-line1match.txt +0 -1
- data/test/snapshots/error_no_such_mixin/out-sdiff.txt +0 -12
- data/test/snapshots/lines.txt +0 -124
- 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
@@ -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>'
|
@@ -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'
|
data/test/snapshots/lines.txt
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
Check output of $$date
|
2
|
-
Today is $$date, I guess
|
3
|
-
/Today is \d\d\d\d-\d\d-\d\d, I guess/
|
4
|
-
|
5
|
-
Check output of $$time
|
6
|
-
Tick tock, it's $$time right now
|
7
|
-
/Tick tock, it's \d\d:\d\d:\d\d right now/
|
8
|
-
|
9
|
-
Trying $$b function, no param
|
10
|
-
This is $$b being called
|
11
|
-
This is <b>NO PARAMETER</b> being called
|
12
|
-
|
13
|
-
Trying $$b function, brackets
|
14
|
-
This is $$b[bold text] being called
|
15
|
-
This is <b>bold text</b> being called
|
16
|
-
|
17
|
-
Trying $$b function, unterminated brackets
|
18
|
-
This is $$b[bold text being called
|
19
|
-
This is <b>bold text being called</b>
|
20
|
-
|
21
|
-
Trying $$b function, colon param
|
22
|
-
This is $$b:token being called
|
23
|
-
This is <b>token</b> being called
|
24
|
-
|
25
|
-
Try $$i
|
26
|
-
There is $$i[some text] here
|
27
|
-
There is <i>some text</i> here
|
28
|
-
|
29
|
-
Try $$t
|
30
|
-
There is $$t[some text] here
|
31
|
-
There is <font size=+1><tt>some text</tt></font> here
|
32
|
-
|
33
|
-
Try $$s
|
34
|
-
There is $$s[some text] here
|
35
|
-
There is <strike>some text</strike> here
|
36
|
-
|
37
|
-
Try $$bi
|
38
|
-
There is $$bi[some text] here
|
39
|
-
There is <b><i>some text</i></b> here
|
40
|
-
|
41
|
-
Try $$bt
|
42
|
-
There is $$bt[some text] here
|
43
|
-
There is <b><font size=+1><tt>some text</tt></font></b> here
|
44
|
-
|
45
|
-
Try $$bs
|
46
|
-
There is $$bs[some text] here
|
47
|
-
There is <b><strike>some text</strike></b> here
|
48
|
-
|
49
|
-
Try $$it
|
50
|
-
There is $$it[some text] here
|
51
|
-
There is <i><font size=+1><tt>some text</tt></font></i> here
|
52
|
-
|
53
|
-
Try $$is
|
54
|
-
There is $$is[some text] here
|
55
|
-
There is <i><strike>some text</strike></i> here
|
56
|
-
|
57
|
-
Try $$ts
|
58
|
-
There is $$ts[some text] here
|
59
|
-
There is <font size=+1><tt><strike>some text</strike></tt></font> here
|
60
|
-
|
61
|
-
Try $$bit
|
62
|
-
There is $$bit[some text] here
|
63
|
-
There is <b><i><font size=+1><tt>some text</tt></font></i></b> here
|
64
|
-
|
65
|
-
Try $$bis
|
66
|
-
There is $$bis[some text] here
|
67
|
-
There is <b><i><strike>some text</strike></i></b> here
|
68
|
-
|
69
|
-
Try $$bts
|
70
|
-
There is $$bts[some text] here
|
71
|
-
There is <b><font size=+1><tt><strike>some text</strike></tt></font></b> here
|
72
|
-
|
73
|
-
Try $$its
|
74
|
-
There is $$its[some text] here
|
75
|
-
There is <i><font size=+1><tt><strike>some text</strike></tt></font></i> here
|
76
|
-
|
77
|
-
Try $$bits
|
78
|
-
There is $$bits[some text] here
|
79
|
-
There is <b><i><font size=+1><tt><strike>some text</strike></tt></font></i></b> here
|
80
|
-
|
81
|
-
Escaped brackets inside bracketed function parameter
|
82
|
-
Here is an $$t[\[:array, :expression\]] with escapes.
|
83
|
-
Here is an <font size=+1><tt>[:array, :expression]</tt></font> with escapes.
|
84
|
-
|
85
|
-
Escape brackets inside *
|
86
|
-
There are brackets *[\[\]] here
|
87
|
-
There are brackets <b>[]</b> here
|
88
|
-
|
89
|
-
Escape brackets inside _
|
90
|
-
There are brackets _[\[\]] here
|
91
|
-
There are brackets <i>[]</i> here
|
92
|
-
|
93
|
-
Escape brackets inside `
|
94
|
-
There are brackets `[\[\]] here
|
95
|
-
There are brackets <font size=+1><tt>[]</tt></font> here
|
96
|
-
|
97
|
-
Escape brackets inside ~
|
98
|
-
There are brackets ~[\[\]] here
|
99
|
-
There are brackets <strike>[]</strike> here
|
100
|
-
|
101
|
-
Line starts with underscore
|
102
|
-
_This for example
|
103
|
-
<i>This</i> for example
|
104
|
-
|
105
|
-
Line starts with double underscore
|
106
|
-
__This, for example
|
107
|
-
<i>This</i>, for example
|
108
|
-
|
109
|
-
Line has embedded underscores
|
110
|
-
This has some_embedded_underscores
|
111
|
-
This has some_embedded_underscores
|
112
|
-
|
113
|
-
Line has escaped underscores
|
114
|
-
This has some\_escaped\_underscores
|
115
|
-
This has some_escaped_underscores
|
116
|
-
|
117
|
-
Doubled underscore, midline
|
118
|
-
This is __doubled, it seems
|
119
|
-
This is <i>doubled</i>, it seems
|
120
|
-
|
121
|
-
Underscore inside parens
|
122
|
-
This is (_italicized and parenthesized)
|
123
|
-
This is (<i>italicized</i> and parenthesized)
|
124
|
-
|
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
|