livetext 0.9.20 → 0.9.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/snapshots.rb CHANGED
@@ -65,15 +65,17 @@ class TestingLivetext < MiniTest::Test
65
65
  TestDirs = Dir.entries(".").reject {|fname| ! File.directory?(fname) } - %w[. ..]
66
66
 
67
67
 
68
- def self.filter # TODO move subset/omit logic here??
69
- puts "Data = #{Data}"
70
- all = Dir.entries(Data).reject {|fname| ! File.directory?(fname) } - %w[. ..]
71
- included, excluded = [], []
68
+ def self.filter
69
+ all = Dir.entries(".").reject {|fname| ! File.directory?(fname) } - %w[. ..]
70
+ @included, @excluded = all, []
71
+ @reasons = []
72
72
  @iflag, @eflag = true, false # defaults to INCLUDE
73
- control = File.new("clusion.txt")
74
- control.each_line do |line|
73
+ control = File.new("subset.txt")
74
+ control.each_line do |raw_line|
75
+ line = raw_line.dup
75
76
  line.sub!(/#.*/, "")
76
77
  line.strip!
78
+ line.chomp!
77
79
  lower = line.downcase
78
80
  dejavu = false
79
81
  case
@@ -85,28 +87,32 @@ puts "Data = #{Data}"
85
87
  dejavu = true
86
88
  when lower == "default exclude all"
87
89
  raise "Only one 'default' allowed" if dejavu
90
+ @included = []
88
91
  @iflag, @eflag = false, true
89
92
  dejavu = true
90
93
  when lower == "quit"
91
94
  break
92
- when lower[0] == "i"
95
+ when lower[0] == "i" && lower[1] == " "
93
96
  TTY.puts "Warning: Can't include with 'i' when that is default" if @iflag
94
- included << line.split(" ", 2)[1] # add to included
95
- when lower[0] == "x"
97
+ val = raw_line.split(" ", 2)[1]
98
+ @included << val unless val.nil? # add to @included
99
+ when lower[0] == "x" && lower[1] == " "
96
100
  TTY.puts "Warning: Can't exclude with 'x' when that is default" if @eflag
97
- excluded << line.split(" ", 2)[1] # add to excluded
98
- # add to excluded
101
+ val, why = raw_line.split(" ", 3).values_at(1, 2)
102
+ @excluded << val unless val.nil? # add to @excluded
103
+ @reasons << why.chomp
99
104
  end
100
- [included, excluded]
101
105
  end
106
+ unless @excluded.empty?
107
+ puts "\nExcluded:\n "
108
+ @excluded.each.with_index do |name, num|
109
+ printf " %-20s %s\n", name, @reasons[num]
110
+ end
111
+ puts
112
+ end
113
+ @included - @excluded
102
114
  end
103
115
 
104
- i, e = self.filter
105
- p i
106
- p e
107
-
108
- exit
109
-
110
116
  def initialize(base, assertion = nil)
111
117
  @assertion = assertion
112
118
  @base = base
@@ -185,26 +191,7 @@ puts "Data = #{Data}"
185
191
  end
186
192
  end
187
193
 
188
- if args.empty?
189
- selected = File.readlines("subset.txt").map(&:chomp)
190
- omitfile = "OMIT.txt"
191
- omitted = File.readlines(omitfile).map(&:chomp)
192
- omitted.reject! {|line| line.start_with?("#") }
193
- omit_names = omitted.map {|line| line.split.first }
194
- STDERR.puts
195
- STDERR.puts " >>> Warning: Omitting #{omitted.size} snapshot tests:\n "
196
- indented = " "*7
197
- omitted.each do |line|
198
- STDERR.print indented
199
- name, info = line.split(" ", 2)
200
- STDERR.printf "%-20s %s\n", name, info
201
- end
202
- STDERR.puts
203
- wanted = selected.empty? ? TestDirs : selected
204
- Subset = wanted - omit_names
205
- else
206
- Subset = args
207
- end
194
+ Subset = Snapshot.filter
208
195
 
209
196
  Subset.each do |tdir|
210
197
  define_method("test_#{tdir}") do
@@ -13,7 +13,7 @@ class TestParseSet < MiniTest::Test
13
13
  def teardown
14
14
  end
15
15
 
16
- def ztest_one_unquoted
16
+ def test_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,38 +23,37 @@ class TestParseSet < MiniTest::Test
23
23
  assert_equal pair, %w[var_234 naked_string]
24
24
  end
25
25
 
26
- def ztest_one_single_quoted
26
+ def test_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 ztest_one_double_quoted
32
+ def test_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 ztest_multiple_unquoted
39
- puts __method__
38
+ def test_multiple_unquoted
40
39
  pair1, pair2 = ParseSet.new("this=345, that=678").parse
41
40
  assert_equal pair1, %w[this 345]
42
41
  assert_equal pair2, %w[that 678]
43
42
  end
44
43
 
45
- def ztest_multiple_unquoted_quoted
44
+ def test_multiple_unquoted_quoted
46
45
  pair1, pair2 = ParseSet.new('alpha = 567, beta = "oh well"').parse
47
46
  assert_equal pair1, %w[alpha 567]
48
47
  assert_equal pair2, ["beta", "oh well"]
49
48
  end
50
49
 
51
- def ztest_quote_embedded_comma
50
+ def test_quote_embedded_comma
52
51
  set = ParseSet.new('gamma = "oh, well"').parse
53
52
  pair = set.first
54
53
  assert_equal pair, ["gamma", "oh, well"]
55
54
  end
56
55
 
57
- def ztest_get_var
56
+ def test_get_var
58
57
  @parse = ParseSet.new("foo=345")
59
58
  assert_equal @parse.get_var, "foo"
60
59
  @parse = ParseSet.new("foo = 345")
@@ -79,7 +78,7 @@ puts __method__
79
78
  assert_raises(BadVariableName) { @parse.get_var }
80
79
  end
81
80
 
82
- def ztest_skip_equal
81
+ def test_skip_equal
83
82
  @parse = ParseSet.new("=")
84
83
  assert_nil @parse.skip_equal
85
84
  @parse = ParseSet.new(" = ")
@@ -97,7 +96,7 @@ puts __method__
97
96
  assert_raises(NoEqualSign) { @parse.skip_equal }
98
97
  end
99
98
 
100
- def ztest_quoted_value
99
+ def test_quoted_value
101
100
  @parse = ParseSet.new(%['this'])
102
101
  assert_equal @parse.quoted_value, "this"
103
102
  @parse = ParseSet.new(%["that"])
@@ -119,7 +118,7 @@ puts __method__
119
118
  # - allow (escaped?) comma in quoted string
120
119
  end
121
120
 
122
- def ztest_unquoted_value
121
+ def test_unquoted_value
123
122
  # Note: an unquoted value is still a string!
124
123
  @parse = ParseSet.new(%[342 ])
125
124
  assert_equal @parse.unquoted_value, "342"
@@ -140,19 +139,22 @@ puts __method__
140
139
 
141
140
  # BUG: FormatLine doesn't know variables in this context!
142
141
 
143
- def xtest_4 # FIXME
142
+ def test_var_eq_var
144
143
  set = ParseSet.new("file = $File").parse
144
+ set = set.first # [["var", "value"]]
145
145
  assert_equal set.first, "file"
146
- assert set.last !~ /undefined/
146
+ refute set.last =~ /undefined/, "Found 'undefined' for variable value"
147
147
  end
148
148
 
149
149
  # BUG: ...or functions.
150
150
  # (Additional bug: Failing silently seems wrong.)
151
151
 
152
- def xtest_5 # FIXME
152
+ def test_var_eq_func
153
153
  set = ParseSet.new("date = $$date").parse
154
+ set = set.first # [["var", "value"]]
154
155
  assert_equal set.first, "date"
155
- assert set.last =~ /^\d\d.\d\d.\d\d/
156
+ refute set.last =~ /undefined/, "Found 'undefined' for variable value"
157
+ assert set.last =~ /^\d\d.\d\d.\d\d/, "Did not find 6-digit date with two separators"
156
158
  end
157
159
 
158
160
  def test_two_strings
@@ -58,7 +58,7 @@ class TestStringParser < MiniTest::Test
58
58
  assert @zero.eos?
59
59
 
60
60
  @one.grab
61
- assert @one.eos?
61
+ assert @one.eos? # FIXME??
62
62
  @one.grab
63
63
  assert @one.eos?
64
64
 
@@ -81,19 +81,15 @@ class TestStringParser < MiniTest::Test
81
81
  assert_nil char1
82
82
  assert_nil char2
83
83
  assert @zero.i == 0
84
- assert @zero.last?
85
84
  assert @zero.eos?
86
85
 
87
- refute @one.last? # FIXME??
88
86
  char1 = @one.peek
89
- refute @one.last? # FIXME??
90
87
  char2 = @one.grab
91
88
  char3 = @one.peek
92
89
  assert char1
93
90
  assert char2 == char1
94
91
  assert char3 == @str1[1]
95
92
  assert @one.i == 1
96
- assert @one.last?
97
93
  assert @one.eos? # FIXME??
98
94
 
99
95
  char1 = @many.peek
@@ -103,7 +99,6 @@ class TestStringParser < MiniTest::Test
103
99
  assert char2 == char1
104
100
  assert char3 == @strN[1]
105
101
  assert @many.i == 1
106
- refute @many.last?
107
102
  refute @many.eos?
108
103
  end
109
104
 
@@ -126,5 +121,49 @@ class TestStringParser < MiniTest::Test
126
121
  refute some.peek == " "
127
122
  assert_equal some.peek, "x"
128
123
  assert_equal some.i, 3
124
+
125
+ some = StringParser.new("abc 123")
126
+ 3.times { some.grab }
127
+ assert_equal some.peek, " "
128
+ some.skip_spaces
129
+ refute some.peek == " "
130
+ assert_equal some.peek, "1"
131
+ assert_equal some.i, 6
132
+ end
133
+
134
+ def test_ungrab
135
+ parse = StringParser.new("abcdef")
136
+ assert_equal parse.i, 0
137
+ assert_equal parse.peek, "a"
138
+ 3.times { parse.grab }
139
+ assert_equal parse.i, 3
140
+ assert_equal parse.peek, "d"
141
+ parse.ungrab
142
+ assert_equal parse.i, 2
143
+ assert_equal parse.peek, "c"
144
+ end
145
+
146
+ def test_next_bang
147
+ parse = StringParser.new("abcdef")
148
+ assert_equal parse.peek, "a"
149
+ assert_equal parse.next!, "b"
150
+ assert_equal parse.i, 0
151
+ 3.times { parse.grab }
152
+ before = parse.i
153
+ assert_equal parse.next!, "e"
154
+ after = parse.i
155
+ assert_equal before, after
156
+ end
157
+
158
+ def test_prev
159
+ parse = StringParser.new("abcdef")
160
+ assert_nil parse.prev
161
+ assert_equal parse.i, 0
162
+ 3.times { parse.grab }
163
+ before = parse.i
164
+ assert_equal parse.prev, "c"
165
+ after = parse.i
166
+ assert_equal before, after
129
167
  end
168
+
130
169
  end
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.20
4
+ version: 0.9.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-01-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A smart text processor extensible in Ruby
14
14
  email: rubyhacker@gmail.com
@@ -54,21 +54,14 @@ files:
54
54
  - plugin/markdown.rb
55
55
  - plugin/pyggish.rb
56
56
  - plugin/tutorial.rb
57
- - test/affirm/kbks.jpg
58
- - test/affirm/lm-kbks.lt
59
57
  - test/all.rb
60
- - test/cleanup
61
- - test/newtest
62
- - test/sdtest
63
58
  - test/snapshots.rb
64
- - test/snapshots/OMIT.txt
65
59
  - test/snapshots/basic_formatting/expected-error.txt
66
60
  - test/snapshots/basic_formatting/expected-output.txt
67
61
  - test/snapshots/basic_formatting/source.lt3
68
62
  - test/snapshots/block_comment/expected-error.txt
69
63
  - test/snapshots/block_comment/expected-output.txt
70
64
  - test/snapshots/block_comment/source.lt3
71
- - test/snapshots/clusion.txt
72
65
  - test/snapshots/comments_ignored_1/expected-error.txt
73
66
  - test/snapshots/comments_ignored_1/expected-output.txt
74
67
  - test/snapshots/comments_ignored_1/source.lt3
@@ -76,7 +69,6 @@ files:
76
69
  - test/snapshots/copy_is_raw/expected-output.txt
77
70
  - test/snapshots/copy_is_raw/rawtext.inc
78
71
  - test/snapshots/copy_is_raw/source.lt3
79
- - test/snapshots/crap
80
72
  - test/snapshots/def_method/expected-error.txt
81
73
  - test/snapshots/def_method/expected-output.txt
82
74
  - test/snapshots/def_method/source.lt3
@@ -114,7 +106,6 @@ files:
114
106
  - test/snapshots/example_alpha2/expected-error.txt
115
107
  - test/snapshots/example_alpha2/expected-output.txt
116
108
  - test/snapshots/example_alpha2/source.lt3
117
- - test/snapshots/fixit
118
109
  - test/snapshots/functions/expected-error.txt
119
110
  - test/snapshots/functions/expected-output.txt
120
111
  - test/snapshots/functions/source.lt3
data/test/affirm/kbks.jpg DELETED
Binary file
@@ -1,19 +0,0 @@
1
- .mixin livemagick
2
-
3
- .nopass
4
-
5
- .image 300 100 lightgray
6
- .canvas green 1 0
7
- .pen red red
8
- .font 80 Arial
9
-
10
- .rectangle 100,50 300x300 green 9
11
-
12
- .text! 100,50 100x100
13
- K B K Z
14
- .end
15
- .draw
16
- .save! myfile.jpg
17
-
18
- .def foobar
19
-
data/test/cleanup DELETED
@@ -1 +0,0 @@
1
- find testfiles -name actual-*.txt | xargs rm
data/test/newtest DELETED
@@ -1,14 +0,0 @@
1
- mkdir test/data/$1
2
-
3
- # actual-error.txt actual-output.txt expected-error.txt expected-output.txt source.lt3
4
-
5
- cd test/data/$1
6
-
7
- touch expected-output.txt expected-error.txt
8
-
9
- vi source.lt3
10
-
11
- livetext source.lt3 >expected-output.txt 2>expected-error.txt
12
-
13
- vi -O source.lt3 expected-output.txt expected-error.txt
14
-
data/test/sdtest DELETED
@@ -1,6 +0,0 @@
1
-
2
- sdiff test/data/$1/expected-output.txt /tmp/$1--actual-output.txt
3
-
4
- echo ==========
5
-
6
- sdiff test/data/$1/expected-error.txt /tmp/$1--actual-error.txt
@@ -1,11 +0,0 @@
1
- # Comments are ignored.
2
- # Other lines: name_of_snapshot and any comments here are ignored (no # needed)
3
- # fake_test_name Use # to un-omit ;)
4
- error_no_such_inc Output BEFORE error doesn't get passed through
5
- error_no_such_copy ^ Same behavior as error_no_such_inc
6
- error_no_such_mixin ^ Same behavior as error_missing_end
7
- error_invalid_name ^ Same behavior as error_no_such_inc
8
- error_missing_end Output is duplicated somehow. Look for: puts @body or puts @main.body
9
- error_inc_line_num Forgot what's wrong here
10
- simple_import Not coded yet
11
- icanhaz Dummy command similar to import/mixin
@@ -1,84 +0,0 @@
1
- # This file specifies which snapshots will/won't be run.
2
-
3
- # Blank lines and comments are ignored.
4
- # Other lines: name_of_snapshot and any comments here are ignored (no # needed)
5
-
6
- # You can start by uncommenting one of these:
7
- # Default INCLUDE all
8
- # Default EXCLUDE all
9
- # If you use neither, INCLUDE is the default (but explicit is better)
10
-
11
- # If you include all, you can specify exclusions with an x:
12
- # x my_test_name # this is a comment
13
-
14
- # Likewise if you EXCLUDE all, you can specify inclusions with an i:
15
- # i some_other_test # this is a comment
16
-
17
- # The i and x (to include/exclude) must be the first token on
18
- # the line (preceding the test name)
19
-
20
- # Note that QUIT (on a line by itself) will stop processing the file
21
-
22
- x error_no_such_inc # Output BEFORE error doesn't get passed through ("leading" output)
23
- x error_no_such_copy # ^ Same behavior as error_no_such_inc
24
- x error_no_such_mixin # ^ Same behavior as error_missing_end
25
- x error_invalid_name # ^ Same behavior as error_no_such_inc
26
- x error_missing_end # Output is duplicated somehow. Look for: puts @body or puts @main.body
27
- x error_inc_line_num # Forgot what's wrong here
28
-
29
- # Dummy command .icanhaz works like .mixin or .import
30
-
31
- x icanhaz # "Leading" output doesn't get generated (same as error_no_such_inc)
32
- icanhaz2
33
-
34
- # Others (usually passing):
35
-
36
- # import/include/mixin, others...
37
-
38
- simple_copy #
39
- simple_import #
40
- simple_include #
41
- simple_mixin #
42
-
43
- # raw input
44
-
45
- single_raw_line #
46
- raw_lines #
47
- raw_text_block #
48
- copy_is_raw #
49
-
50
- # comments
51
-
52
- block_comment #
53
- comments_ignored_1 #
54
-
55
- # variables and heredocs
56
-
57
- predef_vars #
58
- simple_vars #
59
- more_complex_vars #
60
- table_with_heredocs #
61
-
62
- # testing def
63
-
64
- def_method #
65
-
66
- # intraline formatting
67
-
68
- basic_formatting #
69
-
70
- # Errors
71
-
72
- error_line_num #
73
- error_mismatched_end #
74
- error_name_not_permitted #
75
-
76
- # functions
77
-
78
- functions #
79
-
80
- # More/misc...
81
-
82
- example_alpha #
83
- example_alpha2 #
84
- hello_world #
data/test/snapshots/crap DELETED
@@ -1,16 +0,0 @@
1
- ./fixit block_comment
2
- ./fixit comments_ignored_1
3
- ./fixit comments_ignored_2
4
- ./fixit copy_is_raw
5
- ./fixit def_method
6
- ./fixit example_alpha
7
- ./fixit example_alpha2
8
- ./fixit hello_world
9
- ./fixit more_complex_vars
10
- ./fixit raw_text_block
11
- ./fixit sigil_can_change
12
- ./fixit simple_copy
13
- ./fixit simple_include
14
- ./fixit simple_mixin
15
- ./fixit simple_vars
16
- ./fixit single_raw_line
data/test/snapshots/fixit DELETED
@@ -1,6 +0,0 @@
1
- cd $1
2
- mv $1.err actual-error.txt
3
- mv $1.erx expected-error.txt
4
- mv $1.exp expected-output.txt
5
- mv $1.lt3 source.lt3
6
- mv $1.out actual-output.txt