livetext 0.9.13 → 0.9.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/README.lt3 +2 -2
  3. data/imports/bookish.rb +288 -0
  4. data/imports/calibre.rb +28 -0
  5. data/imports/livemagick.rb +133 -0
  6. data/imports/markdown.rb +44 -0
  7. data/imports/markdown_importable.rb +46 -0
  8. data/imports/pyggish.rb +204 -0
  9. data/imports/tutorial.rb +95 -0
  10. data/lib/cmdargs.rb +93 -0
  11. data/lib/errors.rb +4 -2
  12. data/lib/formatline.rb +56 -83
  13. data/lib/functions.rb +1 -1
  14. data/lib/handler/icanhaz.rb +35 -0
  15. data/lib/handler.rb +1 -0
  16. data/lib/helpers.rb +177 -4
  17. data/lib/livetext.rb +20 -139
  18. data/lib/parser/file.rb +8 -0
  19. data/lib/parser/general.rb +1 -1
  20. data/lib/parser/import.rb +1 -3
  21. data/lib/parser/mixin.rb +22 -30
  22. data/lib/parser/set.rb +35 -26
  23. data/lib/parser/string.rb +19 -4
  24. data/lib/processor.rb +2 -12
  25. data/lib/standard.rb +73 -107
  26. data/lib/userapi.rb +1 -4
  27. data/livetext.gemspec +2 -1
  28. data/plugin/bookish.rb +26 -22
  29. data/plugin/calibre.rb +1 -1
  30. data/plugin/livemagick.rb +10 -10
  31. data/plugin/markdown.rb +13 -11
  32. data/plugin/pyggish.rb +94 -84
  33. data/plugin/tutorial.rb +10 -5
  34. data/test/snapshots/OMIT.txt +11 -0
  35. data/test/snapshots/clusion.txt +84 -0
  36. data/test/snapshots/error_inc_line_num/match-error.txt +1 -0
  37. data/test/snapshots/error_invalid_name/match-error.txt +1 -0
  38. data/test/snapshots/error_line_num/match-error.txt +1 -0
  39. data/test/snapshots/error_mismatched_end/expected-output.txt +0 -2
  40. data/test/snapshots/error_mismatched_end/match-error.txt +1 -0
  41. data/test/snapshots/error_missing_end/match-error.txt +1 -0
  42. data/test/snapshots/error_no_such_copy/match-error.txt +1 -0
  43. data/test/snapshots/error_no_such_copy/source.lt3 +0 -1
  44. data/test/snapshots/error_no_such_inc/match-error.txt +1 -0
  45. data/test/snapshots/error_no_such_mixin/match-error.txt +1 -0
  46. data/test/snapshots/icanhaz/expected-output.txt +5 -0
  47. data/test/snapshots/icanhaz/match-error.txt +1 -0
  48. data/test/snapshots/icanhaz/simple_import.rb +5 -0
  49. data/test/snapshots/{error_no_such_mixin/actual-output.txt → icanhaz/source.lt3} +3 -4
  50. data/test/snapshots/{error_invalid_name/actual-output.txt → icanhaz2/expected-error.txt} +0 -0
  51. data/test/snapshots/icanhaz2/expected-output.txt +6 -0
  52. data/test/snapshots/icanhaz2/simple_canhaz.rb +5 -0
  53. data/test/snapshots/icanhaz2/source.lt3 +6 -0
  54. data/test/snapshots/predef_vars/match-output.txt +6 -0
  55. data/test/snapshots/{error_no_such_copy/actual-output.txt → simple_import/expected-error.txt} +0 -0
  56. data/test/snapshots/simple_import/expected-output.txt +7 -0
  57. data/test/snapshots/simple_import/simple_import.rb +5 -0
  58. data/test/snapshots/simple_import/source.lt3 +7 -0
  59. data/test/snapshots/simple_include/source.lt3 +0 -1
  60. data/test/snapshots.rb +103 -107
  61. data/test/unit/all.rb +1 -0
  62. data/test/unit/formatline.rb +650 -0
  63. data/test/unit/parser/general.rb +21 -21
  64. data/test/unit/parser/importable.rb +1 -1
  65. data/test/unit/parser/mixin.rb +2 -2
  66. data/test/unit/parser/set.rb +19 -12
  67. data/test/unit/parser/string.rb +14 -14
  68. data/test/unit/parser.rb +2 -0
  69. metadata +37 -46
  70. data/test/formatting.rb +0 -103
  71. data/test/snapshots/error_inc_line_num/actual-error.txt +0 -1
  72. data/test/snapshots/error_inc_line_num/actual-output.txt +0 -13
  73. data/test/snapshots/error_inc_line_num/expected-err-line1match.txt +0 -1
  74. data/test/snapshots/error_inc_line_num/out-sdiff.txt +0 -14
  75. data/test/snapshots/error_invalid_name/actual-error.txt +0 -10
  76. data/test/snapshots/error_invalid_name/expected-err-line1match.txt +0 -1
  77. data/test/snapshots/error_invalid_name/out-sdiff.txt +0 -6
  78. data/test/snapshots/error_line_num/actual-error.txt +0 -1
  79. data/test/snapshots/error_line_num/actual-output.txt +0 -5
  80. data/test/snapshots/error_line_num/expected-err-line1match.txt +0 -1
  81. data/test/snapshots/error_line_num/out-sdiff.txt +0 -6
  82. data/test/snapshots/error_mismatched_end/actual-error.txt +0 -1
  83. data/test/snapshots/error_mismatched_end/actual-output.txt +0 -8
  84. data/test/snapshots/error_mismatched_end/expected-err-line1match.txt +0 -1
  85. data/test/snapshots/error_mismatched_end/out-sdiff.txt +0 -9
  86. data/test/snapshots/error_missing_end/actual-error.txt +0 -1
  87. data/test/snapshots/error_missing_end/actual-output.txt +0 -5
  88. data/test/snapshots/error_missing_end/expected-err-line1match.txt +0 -1
  89. data/test/snapshots/error_missing_end/out-sdiff.txt +0 -6
  90. data/test/snapshots/error_name_not_permitted/OLD-exp-out +0 -4
  91. data/test/snapshots/error_no_such_copy/actual-error.txt +0 -10
  92. data/test/snapshots/error_no_such_copy/expected-err-line1match.txt +0 -1
  93. data/test/snapshots/error_no_such_copy/out-sdiff.txt +0 -5
  94. data/test/snapshots/error_no_such_inc/actual-error.txt +0 -10
  95. data/test/snapshots/error_no_such_inc/actual-output.txt +0 -0
  96. data/test/snapshots/error_no_such_inc/expected-err-line1match.txt +0 -1
  97. data/test/snapshots/error_no_such_inc/out-sdiff.txt +0 -6
  98. data/test/snapshots/error_no_such_mixin/actual-error.txt +0 -1
  99. data/test/snapshots/error_no_such_mixin/expected-err-line1match.txt +0 -1
  100. data/test/snapshots/error_no_such_mixin/out-sdiff.txt +0 -12
  101. data/test/snapshots/lines.txt +0 -124
  102. data/test/snapshots/predef_vars/actual-error.txt +0 -0
  103. data/test/snapshots/predef_vars/actual-output.txt +0 -6
  104. data/test/snapshots/predef_vars/expected-output.txt +0 -6
  105. data/test/snapshots/predef_vars/out-sdiff.txt +0 -7
  106. data/test/snapshots/simple_mixin/actual-error.txt +0 -2
  107. data/test/snapshots/simple_mixin/actual-output.txt +0 -4
  108. data/test/snapshots/simple_mixin/out-sdiff.txt +0 -6
  109. data/test/unit/parse_misc.rb +0 -60
  110. data/test/unit/parse_set.rb +0 -157
@@ -3,9 +3,9 @@ require 'minitest/autorun'
3
3
 
4
4
  require_relative '../../../lib/parser/general'
5
5
 
6
- ParseMisc = ::Livetext::ParseMisc
6
+ ParseGeneral = ::Livetext::ParseGeneral
7
7
 
8
- class TestParseMisc < MiniTest::Test
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) { ParseMisc.new(nil).strip_quotes }
18
- assert_raises(NullString) { ParseMisc.new("").strip_quotes }
19
- assert_raises(MismatchedQuotes) { ParseMisc.new(%['test]).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
-
26
- assert ParseMisc.new(%[24601]).strip_quotes == "24601", "Failure 1"
27
- assert ParseMisc.new(%[3.14]).strip_quotes == "3.14", "Failure 2"
28
- assert ParseMisc.new(%[test]).strip_quotes == "test", "Failure 3"
29
- assert ParseMisc.new(%['test']).strip_quotes == "test", "Failure 4"
30
- assert ParseMisc.new(%["test"]).strip_quotes == "test", "Failure 5"
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 ParseMisc.parse_vars(vars), expect
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 ParseMisc.parse_vars(vars), expect
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 ParseMisc.parse_vars(vars), expect
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 ParseMisc.parse_vars(vars, prefix: "this"), expect
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 ParseMisc.parse_vars(vars, prefix: "this.that"), expect
55
+ assert_equal ParseGeneral.parse_vars(vars, prefix: "this.that"), expect
56
56
 
57
57
  end
58
58
 
@@ -3,7 +3,7 @@ require 'minitest/autorun'
3
3
 
4
4
  require_relative '../../../lib/parser/set'
5
5
 
6
- ParseSet = Livetext::ParseSet
6
+ # ParseSet = Livetext::ParseSet
7
7
 
8
8
  class TestParseSet < MiniTest::Test
9
9
 
@@ -1,9 +1,9 @@
1
1
 
2
2
  require 'minitest/autorun'
3
3
 
4
- require_relative 'set'
4
+ require_relative '../../../lib/parser/set'
5
5
 
6
- ParseSet = Livetext::ParseSet
6
+ # ParseSet = Livetext::ParseSet
7
7
 
8
8
  class TestParseSet < MiniTest::Test
9
9
 
@@ -13,7 +13,7 @@ class TestParseSet < MiniTest::Test
13
13
  def teardown
14
14
  end
15
15
 
16
- def test_one_unquoted
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 test_one_single_quoted
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 test_one_double_quoted
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 test_multiple_unquoted
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 test_multiple_unquoted_quoted
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 test_quote_embedded_comma
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 test_get_var
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 test_skip_equal
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 test_quoted_value
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 test_unquoted_value
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
@@ -35,14 +35,14 @@ class TestStringParser < MiniTest::Test
35
35
  assert_equal @many.i, 0
36
36
  end
37
37
 
38
- def test_next
39
- assert_nil @zero.next
38
+ def test_grab
39
+ assert_nil @zero.grab
40
40
  assert_equal @zero.i, 0 # nothing happens
41
41
 
42
- assert_equal @one.next, "x"
42
+ assert_equal @one.grab, "x"
43
43
  assert_equal @one.i, 1
44
44
 
45
- assert_equal @many.next, "T"
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 test_next_eos
57
- @zero.next
56
+ def test_grab_eos
57
+ @zero.grab
58
58
  assert @zero.eos?
59
59
 
60
- @one.next
60
+ @one.grab
61
61
  assert @one.eos?
62
- @one.next
62
+ @one.grab
63
63
  assert @one.eos?
64
64
 
65
- @many.next
65
+ @many.grab
66
66
  refute @many.eos?
67
67
  count = @many.len # doesn't make sense??
68
- count.times { @many.next }
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 test_next_peek
79
- char1 = @zero.next
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.next
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.next
100
+ char2 = @many.grab
101
101
  char3 = @many.peek
102
102
  assert char1
103
103
  assert char2 == char1
data/test/unit/parser.rb CHANGED
@@ -2,3 +2,5 @@
2
2
  require_relative 'parser/string'
3
3
  require_relative 'parser/set'
4
4
  require_relative 'parser/general'
5
+ require_relative 'parser/mixin' # currently empty
6
+ require_relative 'parser/importable' # currently empty
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.13
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: 2021-12-23 00:00:00.000000000 Z
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/out-sdiff.txt
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/out-sdiff.txt
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/out-sdiff.txt
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/out-sdiff.txt
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/out-sdiff.txt
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/out-sdiff.txt
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/out-sdiff.txt
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/out-sdiff.txt
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/lines.txt
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/expected-output.txt
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
- "" + str + ""
57
- end
58
-
59
- def red(str)
60
- "" + str + ""
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,13 +0,0 @@
1
- This is my
2
- source file
3
- which includes file2 here:
4
- This is file2
5
- which has an error
6
- about an unknown command
7
- in line 5
8
- <p>
9
-
10
- And this is file2 line 7.
11
- And here we are
12
- back in the
13
- original file.
@@ -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,6 +0,0 @@
1
- EXPECTED | ACTUAL
2
- > This file has
3
- > a defined method
4
- > that is invalid:
5
- > <p>
6
- >
@@ -1 +0,0 @@
1
- Error: Name 'foobar' is unknown
@@ -1,5 +0,0 @@
1
- This file
2
- will have an error
3
- on line 4
4
- if all goes
5
- well.
@@ -1 +0,0 @@
1
- Error: Name 'foobar' is unknown
@@ -1,6 +0,0 @@
1
- EXPECTED | ACTUAL
2
- This file This file
3
- will have an error will have an error
4
- on line 4 on line 4
5
- if all goes <
6
- well. <
@@ -1 +0,0 @@
1
- Error: Name 'end' is unknown