livetext 0.9.14 → 0.9.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cmdargs.rb +93 -0
- data/lib/formatline.rb +56 -83
- data/lib/helpers.rb +142 -4
- data/lib/livetext.rb +11 -141
- data/lib/parser/file.rb +8 -0
- data/lib/parser/mixin.rb +28 -15
- data/lib/parser/set.rb +35 -26
- data/lib/parser/string.rb +19 -4
- data/lib/processor.rb +1 -4
- data/lib/standard.rb +56 -96
- 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/all.rb +0 -1
- data/test/snapshots/OMIT.txt +7 -8
- data/test/snapshots/clusion.txt +35 -0
- data/test/snapshots/error_inc_line_num/actual-error.txt +14 -0
- data/test/snapshots/error_inc_line_num/actual-output.txt +7 -0
- data/test/snapshots/error_inc_line_num/match-error.txt +1 -1
- data/test/snapshots/error_inc_line_num/out-sdiff.txt +14 -0
- data/test/snapshots/error_invalid_name/actual-error.txt +10 -0
- data/test/snapshots/error_invalid_name/actual-output.txt +0 -0
- data/test/snapshots/error_invalid_name/match-error.txt +1 -1
- data/test/snapshots/error_invalid_name/out-sdiff.txt +6 -0
- data/test/snapshots/error_line_num/match-error.txt +1 -1
- data/test/snapshots/error_mismatched_end/match-error.txt +1 -1
- data/test/snapshots/error_missing_end/actual-error.txt +10 -0
- data/test/snapshots/error_missing_end/actual-output.txt +0 -0
- data/test/snapshots/error_missing_end/match-error.txt +1 -1
- data/test/snapshots/error_missing_end/out-sdiff.txt +6 -0
- data/test/snapshots/error_no_such_copy/actual-error.txt +10 -0
- data/test/snapshots/error_no_such_copy/actual-output.txt +0 -0
- data/test/snapshots/error_no_such_copy/match-error.txt +1 -1
- data/test/snapshots/error_no_such_copy/out-sdiff.txt +5 -0
- data/test/snapshots/error_no_such_copy/source.lt3 +0 -1
- data/test/snapshots/error_no_such_inc/actual-error.txt +10 -0
- data/test/snapshots/error_no_such_inc/actual-output.txt +0 -0
- data/test/snapshots/error_no_such_inc/match-error.txt +1 -1
- data/test/snapshots/error_no_such_inc/out-sdiff.txt +6 -0
- data/test/snapshots/error_no_such_mixin/actual-error.txt +37 -0
- data/test/snapshots/error_no_such_mixin/actual-output.txt +0 -0
- data/test/snapshots/error_no_such_mixin/out-sdiff.txt +6 -0
- data/test/snapshots/simple_import/actual-error.txt +8 -0
- data/test/snapshots/simple_import/actual-output.txt +3 -0
- data/test/snapshots/simple_import/err-sdiff.txt +9 -0
- data/test/snapshots/simple_import/expected-error.txt +0 -0
- data/test/snapshots/simple_import/expected-output.txt +7 -0
- data/test/snapshots/simple_import/out-sdiff.txt +9 -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 +3 -2
- data/test/unit/all.rb +1 -0
- data/test/unit/formatline.rb +650 -0
- data/test/unit/parser/importable.rb +1 -1
- data/test/unit/parser/mixin.rb +1 -1
- data/test/unit/parser/set.rb +19 -12
- data/test/unit/parser/string.rb +14 -14
- metadata +32 -5
- data/test/formatting-tests.rb +0 -35
- data/test/formatting.rb +0 -103
- data/test/snapshots/formatting-tests.txt +0 -124
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
|
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.15
|
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,6 +20,7 @@ files:
|
|
20
20
|
- "./README.lt3"
|
21
21
|
- "./README.md"
|
22
22
|
- bin/livetext
|
23
|
+
- lib/cmdargs.rb
|
23
24
|
- lib/errors.rb
|
24
25
|
- lib/formatline.rb
|
25
26
|
- lib/functions.rb
|
@@ -28,6 +29,7 @@ files:
|
|
28
29
|
- lib/livetext.rb
|
29
30
|
- lib/livetext/importable.rb
|
30
31
|
- lib/parser.rb
|
32
|
+
- lib/parser/file.rb
|
31
33
|
- lib/parser/general.rb
|
32
34
|
- lib/parser/import.rb
|
33
35
|
- lib/parser/mixin.rb
|
@@ -47,8 +49,6 @@ files:
|
|
47
49
|
- test/affirm/lm-kbks.lt
|
48
50
|
- test/all.rb
|
49
51
|
- test/cleanup
|
50
|
-
- test/formatting-tests.rb
|
51
|
-
- test/formatting.rb
|
52
52
|
- test/newtest
|
53
53
|
- test/sdtest
|
54
54
|
- test/snapshots.rb
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- test/snapshots/block_comment/expected-error.txt
|
60
60
|
- test/snapshots/block_comment/expected-output.txt
|
61
61
|
- test/snapshots/block_comment/source.lt3
|
62
|
+
- test/snapshots/clusion.txt
|
62
63
|
- test/snapshots/comments_ignored_1/expected-error.txt
|
63
64
|
- test/snapshots/comments_ignored_1/expected-output.txt
|
64
65
|
- test/snapshots/comments_ignored_1/source.lt3
|
@@ -70,12 +71,18 @@ files:
|
|
70
71
|
- test/snapshots/def_method/expected-error.txt
|
71
72
|
- test/snapshots/def_method/expected-output.txt
|
72
73
|
- test/snapshots/def_method/source.lt3
|
74
|
+
- test/snapshots/error_inc_line_num/actual-error.txt
|
75
|
+
- test/snapshots/error_inc_line_num/actual-output.txt
|
73
76
|
- test/snapshots/error_inc_line_num/expected-output.txt
|
74
77
|
- test/snapshots/error_inc_line_num/file2.lt3
|
75
78
|
- test/snapshots/error_inc_line_num/match-error.txt
|
79
|
+
- test/snapshots/error_inc_line_num/out-sdiff.txt
|
76
80
|
- test/snapshots/error_inc_line_num/source.lt3
|
81
|
+
- test/snapshots/error_invalid_name/actual-error.txt
|
82
|
+
- test/snapshots/error_invalid_name/actual-output.txt
|
77
83
|
- test/snapshots/error_invalid_name/expected-output.txt
|
78
84
|
- test/snapshots/error_invalid_name/match-error.txt
|
85
|
+
- test/snapshots/error_invalid_name/out-sdiff.txt
|
79
86
|
- test/snapshots/error_invalid_name/source.lt3
|
80
87
|
- test/snapshots/error_line_num/expected-output.txt
|
81
88
|
- test/snapshots/error_line_num/match-error.txt
|
@@ -83,20 +90,32 @@ files:
|
|
83
90
|
- test/snapshots/error_mismatched_end/expected-output.txt
|
84
91
|
- test/snapshots/error_mismatched_end/match-error.txt
|
85
92
|
- test/snapshots/error_mismatched_end/source.lt3
|
93
|
+
- test/snapshots/error_missing_end/actual-error.txt
|
94
|
+
- test/snapshots/error_missing_end/actual-output.txt
|
86
95
|
- test/snapshots/error_missing_end/expected-output.txt
|
87
96
|
- test/snapshots/error_missing_end/match-error.txt
|
97
|
+
- test/snapshots/error_missing_end/out-sdiff.txt
|
88
98
|
- test/snapshots/error_missing_end/source.lt3
|
89
99
|
- test/snapshots/error_name_not_permitted/expected-output.txt
|
90
100
|
- test/snapshots/error_name_not_permitted/match-error.txt
|
91
101
|
- test/snapshots/error_name_not_permitted/source.lt3
|
102
|
+
- test/snapshots/error_no_such_copy/actual-error.txt
|
103
|
+
- test/snapshots/error_no_such_copy/actual-output.txt
|
92
104
|
- test/snapshots/error_no_such_copy/expected-output.txt
|
93
105
|
- test/snapshots/error_no_such_copy/match-error.txt
|
106
|
+
- test/snapshots/error_no_such_copy/out-sdiff.txt
|
94
107
|
- test/snapshots/error_no_such_copy/source.lt3
|
108
|
+
- test/snapshots/error_no_such_inc/actual-error.txt
|
109
|
+
- test/snapshots/error_no_such_inc/actual-output.txt
|
95
110
|
- test/snapshots/error_no_such_inc/expected-output.txt
|
96
111
|
- test/snapshots/error_no_such_inc/match-error.txt
|
112
|
+
- test/snapshots/error_no_such_inc/out-sdiff.txt
|
97
113
|
- test/snapshots/error_no_such_inc/source.lt3
|
114
|
+
- test/snapshots/error_no_such_mixin/actual-error.txt
|
115
|
+
- test/snapshots/error_no_such_mixin/actual-output.txt
|
98
116
|
- test/snapshots/error_no_such_mixin/expected-output.txt
|
99
117
|
- test/snapshots/error_no_such_mixin/match-error.txt
|
118
|
+
- test/snapshots/error_no_such_mixin/out-sdiff.txt
|
100
119
|
- test/snapshots/error_no_such_mixin/source.lt3
|
101
120
|
- test/snapshots/example_alpha/expected-error.txt
|
102
121
|
- test/snapshots/example_alpha/expected-output.txt
|
@@ -105,7 +124,6 @@ files:
|
|
105
124
|
- test/snapshots/example_alpha2/expected-output.txt
|
106
125
|
- test/snapshots/example_alpha2/source.lt3
|
107
126
|
- test/snapshots/fixit
|
108
|
-
- test/snapshots/formatting-tests.txt
|
109
127
|
- test/snapshots/functions/expected-error.txt
|
110
128
|
- test/snapshots/functions/expected-output.txt
|
111
129
|
- test/snapshots/functions/source.lt3
|
@@ -129,6 +147,14 @@ files:
|
|
129
147
|
- test/snapshots/simple_copy/expected-output.txt
|
130
148
|
- test/snapshots/simple_copy/simplefile.inc
|
131
149
|
- test/snapshots/simple_copy/source.lt3
|
150
|
+
- test/snapshots/simple_import/actual-error.txt
|
151
|
+
- test/snapshots/simple_import/actual-output.txt
|
152
|
+
- test/snapshots/simple_import/err-sdiff.txt
|
153
|
+
- test/snapshots/simple_import/expected-error.txt
|
154
|
+
- test/snapshots/simple_import/expected-output.txt
|
155
|
+
- test/snapshots/simple_import/out-sdiff.txt
|
156
|
+
- test/snapshots/simple_import/simple_import.rb
|
157
|
+
- test/snapshots/simple_import/source.lt3
|
132
158
|
- test/snapshots/simple_include/expected-error.txt
|
133
159
|
- test/snapshots/simple_include/expected-output.txt
|
134
160
|
- test/snapshots/simple_include/simplefile.inc
|
@@ -149,6 +175,7 @@ files:
|
|
149
175
|
- test/snapshots/table_with_heredocs/source.lt3
|
150
176
|
- test/testlines.rb
|
151
177
|
- test/unit/all.rb
|
178
|
+
- test/unit/formatline.rb
|
152
179
|
- test/unit/html.rb
|
153
180
|
- test/unit/parser.rb
|
154
181
|
- test/unit/parser/all.rb
|
data/test/formatting-tests.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
|
3
|
-
require_relative '../lib/livetext'
|
4
|
-
|
5
|
-
# Just another testing class. Chill.
|
6
|
-
|
7
|
-
class TestingLivetext < MiniTest::Test
|
8
|
-
|
9
|
-
TestLines = []
|
10
|
-
|
11
|
-
items = []
|
12
|
-
formatting_tests = File.open("formatting-tests.txt")
|
13
|
-
loop do
|
14
|
-
4.times { items << formatting_tests.gets.chomp }
|
15
|
-
# Blank line terminates each "stanza"
|
16
|
-
raise "Oops? #{items.inspect}" unless items.last.empty?
|
17
|
-
TestLines << items
|
18
|
-
break if formatting_tests.eof?
|
19
|
-
end
|
20
|
-
|
21
|
-
TestLines.each.with_index do |item, num|
|
22
|
-
msg, src, exp, blank = *item
|
23
|
-
define_method("test_formatting_#{num}") do
|
24
|
-
actual = FormatLine.parse!(src)
|
25
|
-
# FIXME could simplify assert logic?
|
26
|
-
if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
|
27
|
-
exp = Regexp.compile(exp[1..-2]) # skip slashes
|
28
|
-
assert_match(exp, actual, msg)
|
29
|
-
else
|
30
|
-
assert_equal(exp, actual, msg)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
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,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
|
-
|