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
data/test/unit/parser/general.rb
CHANGED
@@ -3,9 +3,9 @@ require 'minitest/autorun'
|
|
3
3
|
|
4
4
|
require_relative '../../../lib/parser/general'
|
5
5
|
|
6
|
-
|
6
|
+
ParseGeneral = ::Livetext::ParseGeneral
|
7
7
|
|
8
|
-
class
|
8
|
+
class TestParseGeneral < MiniTest::Test
|
9
9
|
|
10
10
|
def setup
|
11
11
|
end
|
@@ -14,45 +14,45 @@ class TestParseMisc < MiniTest::Test
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_strip_quotes
|
17
|
-
assert_raises(NilValue) {
|
18
|
-
assert_raises(NullString) {
|
19
|
-
assert_raises(MismatchedQuotes) {
|
20
|
-
# assert_raises(MismatchedQuotes) {
|
21
|
-
assert_raises(MismatchedQuotes) {
|
22
|
-
# assert_raises(MismatchedQuotes) {
|
23
|
-
assert_raises(MismatchedQuotes) {
|
24
|
-
assert_raises(MismatchedQuotes) {
|
25
|
-
|
26
|
-
assert
|
27
|
-
assert
|
28
|
-
assert
|
29
|
-
assert
|
30
|
-
assert
|
17
|
+
assert_raises(NilValue) { ParseGeneral.new(nil).strip_quotes }
|
18
|
+
assert_raises(NullString) { ParseGeneral.new("").strip_quotes }
|
19
|
+
assert_raises(MismatchedQuotes) { ParseGeneral.new(%['test]).strip_quotes }
|
20
|
+
# assert_raises(MismatchedQuotes) { ParseGeneral.new(%[test']).strip_quotes }
|
21
|
+
assert_raises(MismatchedQuotes) { ParseGeneral.new(%["test]).strip_quotes }
|
22
|
+
# assert_raises(MismatchedQuotes) { ParseGeneral.new(%[test"]).strip_quotes }
|
23
|
+
assert_raises(MismatchedQuotes) { ParseGeneral.new(%["test']).strip_quotes }
|
24
|
+
assert_raises(MismatchedQuotes) { ParseGeneral.new(%['test"]).strip_quotes }
|
25
|
+
|
26
|
+
assert ParseGeneral.new(%[24601]).strip_quotes == "24601", "Failure 1"
|
27
|
+
assert ParseGeneral.new(%[3.14]).strip_quotes == "3.14", "Failure 2"
|
28
|
+
assert ParseGeneral.new(%[test]).strip_quotes == "test", "Failure 3"
|
29
|
+
assert ParseGeneral.new(%['test']).strip_quotes == "test", "Failure 4"
|
30
|
+
assert ParseGeneral.new(%["test"]).strip_quotes == "test", "Failure 5"
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_variables
|
34
34
|
vars = ["foo 234\n", "bar 456\n"]
|
35
35
|
expect = [%w[foo 234], %w[bar 456]]
|
36
|
-
assert_equal
|
36
|
+
assert_equal ParseGeneral.parse_vars(vars), expect
|
37
37
|
|
38
38
|
vars = ["foo2 234", "bar2 456"] # newline irrelevant
|
39
39
|
expect = [%w[foo2 234], %w[bar2 456]]
|
40
|
-
assert_equal
|
40
|
+
assert_equal ParseGeneral.parse_vars(vars), expect
|
41
41
|
|
42
42
|
# quotes are not stripped... hmm
|
43
43
|
vars = ["alpha 'simple string'", 'beta "another string"']
|
44
44
|
expect = [["alpha", "'simple string'"], ["beta", '"another string"']]
|
45
|
-
assert_equal
|
45
|
+
assert_equal ParseGeneral.parse_vars(vars), expect
|
46
46
|
|
47
47
|
# prefix (namespacing)
|
48
48
|
vars = ["alpha 'simple string'", 'beta "another string"']
|
49
49
|
expect = [["this.alpha", "'simple string'"], ["this.beta", '"another string"']]
|
50
|
-
assert_equal
|
50
|
+
assert_equal ParseGeneral.parse_vars(vars, prefix: "this"), expect
|
51
51
|
|
52
52
|
# prefix (namespacing)
|
53
53
|
vars = ["alpha 'simple string'", 'beta "another string"']
|
54
54
|
expect = [["this.that.alpha", "'simple string'"], ["this.that.beta", '"another string"']]
|
55
|
-
assert_equal
|
55
|
+
assert_equal ParseGeneral.parse_vars(vars, prefix: "this.that"), expect
|
56
56
|
|
57
57
|
end
|
58
58
|
|
data/test/unit/parser/mixin.rb
CHANGED
data/test/unit/parser/set.rb
CHANGED
@@ -13,7 +13,7 @@ class TestParseSet < MiniTest::Test
|
|
13
13
|
def teardown
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def ztest_one_unquoted
|
17
17
|
set = ParseSet.new('my_var_123 = 789').parse
|
18
18
|
pair = set.first
|
19
19
|
assert_equal pair, %w[my_var_123 789]
|
@@ -23,37 +23,38 @@ class TestParseSet < MiniTest::Test
|
|
23
23
|
assert_equal pair, %w[var_234 naked_string]
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def ztest_one_single_quoted
|
27
27
|
set = ParseSet.new("fancy.var.name = 'simple string'").parse
|
28
28
|
pair = set.first
|
29
29
|
assert_equal pair, ["fancy.var.name", "simple string"]
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def ztest_one_double_quoted
|
33
33
|
set = ParseSet.new('fancy.var2 = "another string"').parse
|
34
34
|
pair = set.first
|
35
35
|
assert_equal pair, ["fancy.var2", "another string"]
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def ztest_multiple_unquoted
|
39
|
+
puts __method__
|
39
40
|
pair1, pair2 = ParseSet.new("this=345, that=678").parse
|
40
41
|
assert_equal pair1, %w[this 345]
|
41
42
|
assert_equal pair2, %w[that 678]
|
42
43
|
end
|
43
44
|
|
44
|
-
def
|
45
|
+
def ztest_multiple_unquoted_quoted
|
45
46
|
pair1, pair2 = ParseSet.new('alpha = 567, beta = "oh well"').parse
|
46
47
|
assert_equal pair1, %w[alpha 567]
|
47
48
|
assert_equal pair2, ["beta", "oh well"]
|
48
49
|
end
|
49
50
|
|
50
|
-
def
|
51
|
+
def ztest_quote_embedded_comma
|
51
52
|
set = ParseSet.new('gamma = "oh, well"').parse
|
52
53
|
pair = set.first
|
53
54
|
assert_equal pair, ["gamma", "oh, well"]
|
54
55
|
end
|
55
56
|
|
56
|
-
def
|
57
|
+
def ztest_get_var
|
57
58
|
@parse = ParseSet.new("foo=345")
|
58
59
|
assert_equal @parse.get_var, "foo"
|
59
60
|
@parse = ParseSet.new("foo = 345")
|
@@ -78,7 +79,7 @@ class TestParseSet < MiniTest::Test
|
|
78
79
|
assert_raises(BadVariableName) { @parse.get_var }
|
79
80
|
end
|
80
81
|
|
81
|
-
def
|
82
|
+
def ztest_skip_equal
|
82
83
|
@parse = ParseSet.new("=")
|
83
84
|
assert_nil @parse.skip_equal
|
84
85
|
@parse = ParseSet.new(" = ")
|
@@ -96,7 +97,7 @@ class TestParseSet < MiniTest::Test
|
|
96
97
|
assert_raises(NoEqualSign) { @parse.skip_equal }
|
97
98
|
end
|
98
99
|
|
99
|
-
def
|
100
|
+
def ztest_quoted_value
|
100
101
|
@parse = ParseSet.new(%['this'])
|
101
102
|
assert_equal @parse.quoted_value, "this"
|
102
103
|
@parse = ParseSet.new(%["that"])
|
@@ -118,7 +119,7 @@ class TestParseSet < MiniTest::Test
|
|
118
119
|
# - allow (escaped?) comma in quoted string
|
119
120
|
end
|
120
121
|
|
121
|
-
def
|
122
|
+
def ztest_unquoted_value
|
122
123
|
# Note: an unquoted value is still a string!
|
123
124
|
@parse = ParseSet.new(%[342 ])
|
124
125
|
assert_equal @parse.unquoted_value, "342"
|
@@ -139,7 +140,7 @@ class TestParseSet < MiniTest::Test
|
|
139
140
|
|
140
141
|
# BUG: FormatLine doesn't know variables in this context!
|
141
142
|
|
142
|
-
def xtest_4
|
143
|
+
def xtest_4 # FIXME
|
143
144
|
set = ParseSet.new("file = $File").parse
|
144
145
|
assert_equal set.first, "file"
|
145
146
|
assert set.last !~ /undefined/
|
@@ -148,10 +149,16 @@ class TestParseSet < MiniTest::Test
|
|
148
149
|
# BUG: ...or functions.
|
149
150
|
# (Additional bug: Failing silently seems wrong.)
|
150
151
|
|
151
|
-
def xtest_5
|
152
|
+
def xtest_5 # FIXME
|
152
153
|
set = ParseSet.new("date = $$date").parse
|
153
154
|
assert_equal set.first, "date"
|
154
155
|
assert set.last =~ /^\d\d.\d\d.\d\d/
|
155
156
|
end
|
156
157
|
|
158
|
+
def test_two_strings
|
159
|
+
line = %[bday="May_31", date="5/31"]
|
160
|
+
set = ParseSet.new(line).parse
|
161
|
+
assert set == [["bday", "May_31"], ["date", "5/31"]]
|
162
|
+
end
|
163
|
+
|
157
164
|
end
|
data/test/unit/parser/string.rb
CHANGED
@@ -35,14 +35,14 @@ class TestStringParser < MiniTest::Test
|
|
35
35
|
assert_equal @many.i, 0
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
assert_nil @zero.
|
38
|
+
def test_grab
|
39
|
+
assert_nil @zero.grab
|
40
40
|
assert_equal @zero.i, 0 # nothing happens
|
41
41
|
|
42
|
-
assert_equal @one.
|
42
|
+
assert_equal @one.grab, "x"
|
43
43
|
assert_equal @one.i, 1
|
44
44
|
|
45
|
-
assert_equal @many.
|
45
|
+
assert_equal @many.grab, "T"
|
46
46
|
refute @many.eos, "EOS was true for #{@many.inspect}"
|
47
47
|
assert_equal @many.i, 1
|
48
48
|
end
|
@@ -53,19 +53,19 @@ class TestStringParser < MiniTest::Test
|
|
53
53
|
refute @many.eos?
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
@zero.
|
56
|
+
def test_grab_eos
|
57
|
+
@zero.grab
|
58
58
|
assert @zero.eos?
|
59
59
|
|
60
|
-
@one.
|
60
|
+
@one.grab
|
61
61
|
assert @one.eos?
|
62
|
-
@one.
|
62
|
+
@one.grab
|
63
63
|
assert @one.eos?
|
64
64
|
|
65
|
-
@many.
|
65
|
+
@many.grab
|
66
66
|
refute @many.eos?
|
67
67
|
count = @many.len # doesn't make sense??
|
68
|
-
count.times { @many.
|
68
|
+
count.times { @many.grab }
|
69
69
|
assert @many.eos?
|
70
70
|
end
|
71
71
|
|
@@ -75,8 +75,8 @@ class TestStringParser < MiniTest::Test
|
|
75
75
|
assert_equal @many.peek, @strN[0]
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
79
|
-
char1 = @zero.
|
78
|
+
def test_grab_peek
|
79
|
+
char1 = @zero.grab
|
80
80
|
char2 = @zero.peek
|
81
81
|
assert_nil char1
|
82
82
|
assert_nil char2
|
@@ -87,7 +87,7 @@ class TestStringParser < MiniTest::Test
|
|
87
87
|
refute @one.last? # FIXME??
|
88
88
|
char1 = @one.peek
|
89
89
|
refute @one.last? # FIXME??
|
90
|
-
char2 = @one.
|
90
|
+
char2 = @one.grab
|
91
91
|
char3 = @one.peek
|
92
92
|
assert char1
|
93
93
|
assert char2 == char1
|
@@ -97,7 +97,7 @@ class TestStringParser < MiniTest::Test
|
|
97
97
|
assert @one.eos? # FIXME??
|
98
98
|
|
99
99
|
char1 = @many.peek
|
100
|
-
char2 = @many.
|
100
|
+
char2 = @many.grab
|
101
101
|
char3 = @many.peek
|
102
102
|
assert char1
|
103
103
|
assert char2 == char1
|
data/test/unit/parser.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A smart text processor extensible in Ruby
|
14
14
|
email: rubyhacker@gmail.com
|
@@ -20,14 +20,25 @@ files:
|
|
20
20
|
- "./README.lt3"
|
21
21
|
- "./README.md"
|
22
22
|
- bin/livetext
|
23
|
+
- imports/bookish.rb
|
24
|
+
- imports/calibre.rb
|
25
|
+
- imports/livemagick.rb
|
26
|
+
- imports/markdown.rb
|
27
|
+
- imports/markdown_importable.rb
|
28
|
+
- imports/pyggish.rb
|
29
|
+
- imports/tutorial.rb
|
30
|
+
- lib/cmdargs.rb
|
23
31
|
- lib/errors.rb
|
24
32
|
- lib/formatline.rb
|
25
33
|
- lib/functions.rb
|
34
|
+
- lib/handler.rb
|
35
|
+
- lib/handler/icanhaz.rb
|
26
36
|
- lib/helpers.rb
|
27
37
|
- lib/html.rb
|
28
38
|
- lib/livetext.rb
|
29
39
|
- lib/livetext/importable.rb
|
30
40
|
- lib/parser.rb
|
41
|
+
- lib/parser/file.rb
|
31
42
|
- lib/parser/general.rb
|
32
43
|
- lib/parser/import.rb
|
33
44
|
- lib/parser/mixin.rb
|
@@ -47,16 +58,17 @@ files:
|
|
47
58
|
- test/affirm/lm-kbks.lt
|
48
59
|
- test/all.rb
|
49
60
|
- test/cleanup
|
50
|
-
- test/formatting.rb
|
51
61
|
- test/newtest
|
52
62
|
- test/sdtest
|
53
63
|
- test/snapshots.rb
|
64
|
+
- test/snapshots/OMIT.txt
|
54
65
|
- test/snapshots/basic_formatting/expected-error.txt
|
55
66
|
- test/snapshots/basic_formatting/expected-output.txt
|
56
67
|
- test/snapshots/basic_formatting/source.lt3
|
57
68
|
- test/snapshots/block_comment/expected-error.txt
|
58
69
|
- test/snapshots/block_comment/expected-output.txt
|
59
70
|
- test/snapshots/block_comment/source.lt3
|
71
|
+
- test/snapshots/clusion.txt
|
60
72
|
- test/snapshots/comments_ignored_1/expected-error.txt
|
61
73
|
- test/snapshots/comments_ignored_1/expected-output.txt
|
62
74
|
- test/snapshots/comments_ignored_1/source.lt3
|
@@ -68,58 +80,33 @@ files:
|
|
68
80
|
- test/snapshots/def_method/expected-error.txt
|
69
81
|
- test/snapshots/def_method/expected-output.txt
|
70
82
|
- 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
83
|
- test/snapshots/error_inc_line_num/expected-output.txt
|
75
84
|
- test/snapshots/error_inc_line_num/file2.lt3
|
76
|
-
- test/snapshots/error_inc_line_num/
|
85
|
+
- test/snapshots/error_inc_line_num/match-error.txt
|
77
86
|
- 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
87
|
- test/snapshots/error_invalid_name/expected-output.txt
|
82
|
-
- test/snapshots/error_invalid_name/
|
88
|
+
- test/snapshots/error_invalid_name/match-error.txt
|
83
89
|
- 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
90
|
- test/snapshots/error_line_num/expected-output.txt
|
88
|
-
- test/snapshots/error_line_num/
|
91
|
+
- test/snapshots/error_line_num/match-error.txt
|
89
92
|
- 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
93
|
- test/snapshots/error_mismatched_end/expected-output.txt
|
94
|
-
- test/snapshots/error_mismatched_end/
|
94
|
+
- test/snapshots/error_mismatched_end/match-error.txt
|
95
95
|
- 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
96
|
- test/snapshots/error_missing_end/expected-output.txt
|
100
|
-
- test/snapshots/error_missing_end/
|
97
|
+
- test/snapshots/error_missing_end/match-error.txt
|
101
98
|
- test/snapshots/error_missing_end/source.lt3
|
102
|
-
- test/snapshots/error_name_not_permitted/OLD-exp-out
|
103
99
|
- test/snapshots/error_name_not_permitted/expected-output.txt
|
104
100
|
- test/snapshots/error_name_not_permitted/match-error.txt
|
105
101
|
- 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
102
|
- test/snapshots/error_no_such_copy/expected-output.txt
|
110
|
-
- test/snapshots/error_no_such_copy/
|
103
|
+
- test/snapshots/error_no_such_copy/match-error.txt
|
111
104
|
- 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
105
|
- test/snapshots/error_no_such_inc/expected-output.txt
|
116
|
-
- test/snapshots/error_no_such_inc/
|
106
|
+
- test/snapshots/error_no_such_inc/match-error.txt
|
117
107
|
- 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
108
|
- test/snapshots/error_no_such_mixin/expected-output.txt
|
122
|
-
- test/snapshots/error_no_such_mixin/
|
109
|
+
- test/snapshots/error_no_such_mixin/match-error.txt
|
123
110
|
- test/snapshots/error_no_such_mixin/source.lt3
|
124
111
|
- test/snapshots/example_alpha/expected-error.txt
|
125
112
|
- test/snapshots/example_alpha/expected-output.txt
|
@@ -134,15 +121,19 @@ files:
|
|
134
121
|
- test/snapshots/hello_world/expected-error.txt
|
135
122
|
- test/snapshots/hello_world/expected-output.txt
|
136
123
|
- test/snapshots/hello_world/source.lt3
|
137
|
-
- test/snapshots/
|
124
|
+
- test/snapshots/icanhaz/expected-output.txt
|
125
|
+
- test/snapshots/icanhaz/match-error.txt
|
126
|
+
- test/snapshots/icanhaz/simple_import.rb
|
127
|
+
- test/snapshots/icanhaz/source.lt3
|
128
|
+
- test/snapshots/icanhaz2/expected-error.txt
|
129
|
+
- test/snapshots/icanhaz2/expected-output.txt
|
130
|
+
- test/snapshots/icanhaz2/simple_canhaz.rb
|
131
|
+
- test/snapshots/icanhaz2/source.lt3
|
138
132
|
- test/snapshots/more_complex_vars/expected-error.txt
|
139
133
|
- test/snapshots/more_complex_vars/expected-output.txt
|
140
134
|
- test/snapshots/more_complex_vars/source.lt3
|
141
|
-
- test/snapshots/predef_vars/actual-error.txt
|
142
|
-
- test/snapshots/predef_vars/actual-output.txt
|
143
135
|
- test/snapshots/predef_vars/expected-error.txt
|
144
|
-
- test/snapshots/predef_vars/
|
145
|
-
- test/snapshots/predef_vars/out-sdiff.txt
|
136
|
+
- test/snapshots/predef_vars/match-output.txt
|
146
137
|
- test/snapshots/predef_vars/source.lt3
|
147
138
|
- test/snapshots/raw_lines/expected-error.txt
|
148
139
|
- test/snapshots/raw_lines/expected-output.txt
|
@@ -155,15 +146,16 @@ files:
|
|
155
146
|
- test/snapshots/simple_copy/expected-output.txt
|
156
147
|
- test/snapshots/simple_copy/simplefile.inc
|
157
148
|
- test/snapshots/simple_copy/source.lt3
|
149
|
+
- test/snapshots/simple_import/expected-error.txt
|
150
|
+
- test/snapshots/simple_import/expected-output.txt
|
151
|
+
- test/snapshots/simple_import/simple_import.rb
|
152
|
+
- test/snapshots/simple_import/source.lt3
|
158
153
|
- test/snapshots/simple_include/expected-error.txt
|
159
154
|
- test/snapshots/simple_include/expected-output.txt
|
160
155
|
- test/snapshots/simple_include/simplefile.inc
|
161
156
|
- test/snapshots/simple_include/source.lt3
|
162
|
-
- test/snapshots/simple_mixin/actual-error.txt
|
163
|
-
- test/snapshots/simple_mixin/actual-output.txt
|
164
157
|
- test/snapshots/simple_mixin/expected-error.txt
|
165
158
|
- test/snapshots/simple_mixin/expected-output.txt
|
166
|
-
- test/snapshots/simple_mixin/out-sdiff.txt
|
167
159
|
- test/snapshots/simple_mixin/simple_mixin.rb
|
168
160
|
- test/snapshots/simple_mixin/source.lt3
|
169
161
|
- test/snapshots/simple_vars/expected-error.txt
|
@@ -178,9 +170,8 @@ files:
|
|
178
170
|
- test/snapshots/table_with_heredocs/source.lt3
|
179
171
|
- test/testlines.rb
|
180
172
|
- test/unit/all.rb
|
173
|
+
- test/unit/formatline.rb
|
181
174
|
- test/unit/html.rb
|
182
|
-
- test/unit/parse_misc.rb
|
183
|
-
- test/unit/parse_set.rb
|
184
175
|
- test/unit/parser.rb
|
185
176
|
- test/unit/parser/all.rb
|
186
177
|
- test/unit/parser/general.rb
|
data/test/formatting.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
|
3
|
-
require_relative '../lib/livetext'
|
4
|
-
|
5
|
-
class TestingLivetext < MiniTest::Test
|
6
|
-
|
7
|
-
TTY = File.open("/dev/tty","w")
|
8
|
-
|
9
|
-
dir = ARGV.first == "cmdline" ? "../" : ""
|
10
|
-
Data = "#{dir}test/data"
|
11
|
-
|
12
|
-
TestLines = []
|
13
|
-
|
14
|
-
Dir.chdir `livetext --path`.chomp if ARGV.first == "cmdline"
|
15
|
-
|
16
|
-
Dir.chdir(Data)
|
17
|
-
|
18
|
-
f = File.open("lines.txt")
|
19
|
-
loop do
|
20
|
-
item = []
|
21
|
-
4.times { item << f.gets.chomp }
|
22
|
-
raise "Oops? #{item.inspect}" unless item.last == ""
|
23
|
-
TestLines << item
|
24
|
-
break if f.eof?
|
25
|
-
end
|
26
|
-
|
27
|
-
if File.size("subset.txt") # == 0
|
28
|
-
puts "Defining via TestLines"
|
29
|
-
TestLines.each.with_index do |item, i|
|
30
|
-
msg, src, exp, blank = *item
|
31
|
-
define_method("test_formatting_#{i}") do
|
32
|
-
actual = FormatLine.parse!(src)
|
33
|
-
if exp[0] == "/" # regex!
|
34
|
-
exp = Regexp.compile(exp[1..-2]) # skip slashes
|
35
|
-
assert_match(exp, actual, msg)
|
36
|
-
else
|
37
|
-
assert_equal(exp, actual, msg)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
TestDirs = Dir.entries(".").reject {|f| ! File.directory?(f) } - %w[. ..]
|
44
|
-
selected = File.readlines("subset.txt").map(&:chomp)
|
45
|
-
Subset = selected.empty? ? TestDirs : selected
|
46
|
-
|
47
|
-
# puts "Subset = #{Subset.inspect}"
|
48
|
-
|
49
|
-
Subset.each do |tdir|
|
50
|
-
define_method("test_#{tdir}") do
|
51
|
-
external_files(tdir)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def green(str)
|
56
|
-
"[32m" + str + "[0m"
|
57
|
-
end
|
58
|
-
|
59
|
-
def red(str)
|
60
|
-
"[31m" + str + "[0m"
|
61
|
-
end
|
62
|
-
|
63
|
-
def external_files(base)
|
64
|
-
Dir.chdir(base) do
|
65
|
-
src, out, exp = "source.lt3", "/tmp/#{base}--actual-output.txt", "expected-output.txt"
|
66
|
-
err, erx = "/tmp/#{base}--actual-error.txt", "expected-error.txt"
|
67
|
-
cmd = "livetext #{src} >#{out} 2>#{err}"
|
68
|
-
system(cmd)
|
69
|
-
output, expected, errors, errexp = File.read(out), File.read(exp), File.read(err), File.read(erx)
|
70
|
-
|
71
|
-
out_ok = output == expected
|
72
|
-
err_ok = errors == errexp
|
73
|
-
nout = output.split("\n").size
|
74
|
-
nexp = expected.split("\n").size
|
75
|
-
bad_out = "--- Expected (#{nexp} lines): \n#{green(expected)}\n--- Output (#{nout} lines): \n#{red(output)}\n"
|
76
|
-
bad_err = "--- Error Expected: \n#{green(errexp)}\n--- Error Output: \n#{red(errors)}\n"
|
77
|
-
|
78
|
-
assert(out_ok, bad_out)
|
79
|
-
assert(err_ok, bad_err)
|
80
|
-
# only on success
|
81
|
-
system("rm -f #{out} #{err}") if out_ok && err_ok
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
=begin
|
89
|
-
|
90
|
-
You can add any ordinary test method above. But so far, all these tests simply
|
91
|
-
call external_files.
|
92
|
-
|
93
|
-
The external_files method works this way:
|
94
|
-
- If the test (caller) method is test_my_silly_feature, then we will
|
95
|
-
look for a directory called data/my_silly_feature
|
96
|
-
- In here, there must be a source.lt3, expected-output.txt, and expected-error.txt
|
97
|
-
- Technically, any of these can be empty
|
98
|
-
- We run livetext on the source and compare actual vs expected (stdout, stderr)
|
99
|
-
- The "real" output gets checked first
|
100
|
-
- Of course, both must compare correctly for the test to pass
|
101
|
-
|
102
|
-
=end
|
103
|
-
|
@@ -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>'
|
@@ -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
|