livetext 0.9.21 → 0.9.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.lt3 +8 -8
- data/bin/livetext +57 -40
- data/imports/bookish.rb +89 -90
- data/imports/calibre.rb +3 -3
- data/imports/livemagick.rb +17 -17
- data/imports/markdown.rb +10 -10
- data/imports/pyggish.rb +15 -47
- data/imports/tutorial.rb +18 -18
- data/lib/cmdargs.rb +10 -6
- data/lib/{errors.rb → livetext/errors.rb} +1 -1
- data/lib/{formatline.rb → livetext/formatline.rb} +69 -125
- data/lib/livetext/funcall.rb +84 -0
- data/lib/{functions.rb → livetext/functions.rb} +16 -3
- data/lib/livetext/global_helpers.rb +37 -0
- data/lib/livetext/handler/import.rb +44 -0
- data/lib/livetext/handler/mixin.rb +37 -0
- data/lib/livetext/handler.rb +3 -0
- data/lib/{helpers.rb → livetext/helpers.rb} +89 -67
- data/lib/{html.rb → livetext/html.rb} +3 -2
- data/lib/{parser → livetext/parser}/general.rb +0 -3
- data/lib/{parser → livetext/parser}/set.rb +1 -6
- data/lib/{parser → livetext/parser}/string.rb +2 -2
- data/lib/{parser.rb → livetext/parser.rb} +0 -1
- data/lib/livetext/parsing.rb +29 -0
- data/lib/livetext/paths.rb +13 -0
- data/lib/livetext/processor.rb +89 -0
- data/lib/livetext/reopen.rb +12 -0
- data/lib/livetext/skeleton.rb +17 -0
- data/lib/{standard.rb → livetext/standard.rb} +152 -122
- data/lib/livetext/userapi.rb +153 -0
- data/lib/livetext/version.rb +6 -0
- data/lib/livetext.rb +66 -27
- data/plugin/bookish.rb +85 -85
- data/plugin/calibre.rb +3 -3
- data/plugin/livemagick.rb +17 -17
- data/plugin/markdown.rb +10 -10
- data/plugin/pyggish.rb +131 -162
- data/plugin/tutorial.rb +15 -16
- data/test/all.rb +6 -0
- data/test/snapshots/def_method/expected-output.txt +2 -0
- data/test/snapshots/def_method/source.lt3 +4 -2
- data/test/snapshots/error_inc_line_num/OUT +17 -0
- data/test/snapshots/error_inc_line_num/README.txt +20 -0
- data/test/snapshots/error_inc_line_num/expected-output.txt +0 -6
- data/test/snapshots/error_inc_line_num/match-error.txt +1 -1
- data/test/snapshots/error_line_num/match-error.txt +1 -1
- data/test/snapshots/error_missing_end/expected-output.txt +0 -1
- data/test/snapshots/error_name_not_permitted/expected-output.txt +4 -0
- data/test/snapshots/error_name_not_permitted/match-error.txt +1 -1
- data/test/snapshots/error_no_such_copy/duh +26 -0
- data/test/snapshots/error_no_such_copy/expected-output.txt +1 -0
- data/test/snapshots/error_no_such_copy/match-error.txt +1 -1
- data/test/snapshots/error_no_such_copy/mystery.txt +36 -0
- data/test/snapshots/error_no_such_inc/match-error.txt +1 -1
- data/test/snapshots/error_no_such_mixin/expected-output.txt +1 -0
- data/test/snapshots/error_no_such_mixin/match-error.txt +1 -1
- data/test/snapshots/error_no_such_mixin/source.lt3 +1 -1
- data/test/snapshots/example_alpha/source.lt3 +2 -2
- data/test/snapshots/example_alpha2/expected-output.txt +0 -2
- data/test/snapshots/example_alpha2/source.lt3 +5 -4
- data/test/snapshots/{icanhaz → import}/expected-output.txt +2 -1
- data/test/snapshots/import/match-error.txt +1 -0
- data/test/snapshots/{icanhaz → import}/simple_import.rb +1 -1
- data/test/snapshots/{icanhaz → import}/source.lt3 +2 -2
- data/test/snapshots/{icanhaz2 → import2}/expected-error.txt +0 -0
- data/test/snapshots/{icanhaz2 → import2}/expected-output.txt +3 -1
- data/test/snapshots/{icanhaz2/simple_canhaz.rb → import2/simple_import.rb} +1 -1
- data/test/snapshots/import2/source.lt3 +8 -0
- data/test/snapshots/import_bookish/expected-error.txt +0 -0
- data/test/snapshots/import_bookish/expected-output.txt +10 -0
- data/test/snapshots/import_bookish/source.lt3 +7 -0
- data/test/snapshots/import_bookish/toc.tmp +0 -0
- data/test/snapshots/mixin_bookish/expected-error.txt +0 -0
- data/test/snapshots/mixin_bookish/expected-output.txt +10 -0
- data/test/snapshots/mixin_bookish/source.lt3 +7 -0
- data/test/snapshots/mixin_bookish/toc.tmp +0 -0
- data/test/snapshots/more_functions/expected-error.txt +0 -0
- data/test/snapshots/more_functions/expected-output.txt +37 -0
- data/test/snapshots/more_functions/source.lt3 +40 -0
- data/test/snapshots/raw_lines/expected-output.txt +0 -2
- data/test/snapshots/simple_import/expected-output.txt +2 -0
- data/test/snapshots/simple_import/simple_import.rb +1 -1
- data/test/snapshots/simple_import/source.lt3 +3 -1
- data/test/snapshots/simple_mixin/simple_mixin.rb +1 -1
- data/test/snapshots/single_raw_line/expected-output.txt +0 -2
- data/test/snapshots/subset.txt +14 -14
- data/test/snapshots.rb +30 -13
- data/test/unit/formatline.rb +253 -134
- data/test/unit/html.rb +2 -3
- data/test/unit/parser/general.rb +1 -2
- data/test/unit/parser/mixin.rb +1 -3
- data/test/unit/parser/set.rb +8 -12
- data/test/unit/parser/string.rb +6 -6
- data/test/unit/parser.rb +0 -1
- data/test/unit/standard.rb +0 -2
- metadata +47 -30
- data/imports/markdown_importable.rb +0 -45
- data/lib/handler/icanhaz.rb +0 -35
- data/lib/handler.rb +0 -1
- data/lib/livetext/importable.rb +0 -2
- data/lib/parser/file.rb +0 -8
- data/lib/parser/import.rb +0 -15
- data/lib/parser/mixin.rb +0 -38
- data/lib/processor.rb +0 -83
- data/lib/userapi.rb +0 -160
- data/test/snapshots/icanhaz/match-error.txt +0 -1
- data/test/snapshots/icanhaz2/source.lt3 +0 -6
- data/test/unit/parser/importable.rb +0 -19
@@ -0,0 +1 @@
|
|
1
|
+
1 /file 'nonexistent' not found/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Testing some more functions here...
|
2
|
+
<p>
|
3
|
+
|
4
|
+
Here I am calling a function with
|
5
|
+
a colon parameter...
|
6
|
+
<p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
|
10
|
+
Next let's <b>do*</b> something with our parameter:
|
11
|
+
<p>
|
12
|
+
|
13
|
+
I'll call these variants...
|
14
|
+
<p>
|
15
|
+
|
16
|
+
"Motel" spelled backwards is letom :)
|
17
|
+
<p>
|
18
|
+
|
19
|
+
"lamina" reversed is animal
|
20
|
+
<p>
|
21
|
+
|
22
|
+
I can also use the erutaef tekcarb here.
|
23
|
+
<p>
|
24
|
+
|
25
|
+
If I don't use a parameter for [Error evaluating $$reverse()] - it gives
|
26
|
+
me an error. (Bug or feature??)
|
27
|
+
<p>
|
28
|
+
|
29
|
+
What if a function doesn't use parameters at all, but
|
30
|
+
we pass them? Hmm...
|
31
|
+
<p>
|
32
|
+
|
33
|
+
Now we succeed and succeed some more
|
34
|
+
and finally we succeed in life.
|
35
|
+
<p>
|
36
|
+
|
37
|
+
But can we succeed, when our beds are burning?
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Testing some more functions here...
|
2
|
+
|
3
|
+
.func just_do_it
|
4
|
+
item = param
|
5
|
+
# Do "something" with the parameter...
|
6
|
+
return "" # parameter disappears!
|
7
|
+
.end
|
8
|
+
|
9
|
+
Here I am calling a function $$just_do_it:foobar with
|
10
|
+
a colon parameter...
|
11
|
+
|
12
|
+
|
13
|
+
Next let's *do* something with our parameter:
|
14
|
+
|
15
|
+
.func reverse
|
16
|
+
param.reverse # just reverse it
|
17
|
+
.end
|
18
|
+
|
19
|
+
I'll call these variants...
|
20
|
+
|
21
|
+
"Motel" spelled backwards is $$reverse:motel :)
|
22
|
+
|
23
|
+
"lamina" reversed is $$reverse:lamina
|
24
|
+
|
25
|
+
I can also use the $$reverse[bracket feature] here.
|
26
|
+
|
27
|
+
If I don't use a parameter for $$reverse - it gives
|
28
|
+
me an error. (Bug or feature??)
|
29
|
+
|
30
|
+
What if a function doesn't use parameters at all, but
|
31
|
+
we pass them? Hmm...
|
32
|
+
|
33
|
+
.func meditate
|
34
|
+
"succeed" # just replaces params with this verb
|
35
|
+
.end
|
36
|
+
|
37
|
+
Now we $$meditate:slowly and $$meditate some more
|
38
|
+
and finally we $$meditate[on various things] in life.
|
39
|
+
|
40
|
+
But can we $$meditate, when our beds are burning?
|
data/test/snapshots/subset.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
h This file specifies which snapshots will/won't be run.
|
2
2
|
|
3
3
|
# Blank lines and comments are ignored.
|
4
4
|
# Other lines: name_of_snapshot and any comments here are ignored (no # needed)
|
@@ -19,27 +19,23 @@
|
|
19
19
|
|
20
20
|
# Note that QUIT (on a line by itself) will stop processing the file
|
21
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 # works?
|
33
22
|
|
34
23
|
# Others (usually passing):
|
35
24
|
|
36
25
|
# import/include/mixin, others...
|
37
26
|
|
27
|
+
error_no_such_inc # Output BEFORE error doesn't get passed through ("leading" output)
|
28
|
+
error_no_such_copy # ^ Same behavior as error_no_such_inc
|
29
|
+
error_no_such_mixin # ^ Same behavior as error_missing_end
|
38
30
|
simple_copy #
|
39
|
-
|
31
|
+
simple_import #
|
40
32
|
simple_include #
|
41
33
|
simple_mixin #
|
42
|
-
|
34
|
+
import # "Leading" output doesn't get generated (same as error_no_such_inc)
|
35
|
+
import2 #
|
36
|
+
mixin_bookish #
|
37
|
+
import_bookish #
|
38
|
+
|
43
39
|
# raw input
|
44
40
|
|
45
41
|
single_raw_line #
|
@@ -72,10 +68,14 @@ x simple_import # not working yet (but *could* sub in .icanhaz)
|
|
72
68
|
error_line_num #
|
73
69
|
error_mismatched_end #
|
74
70
|
error_name_not_permitted #
|
71
|
+
error_invalid_name # ^ Same behavior as error_no_such_inc
|
72
|
+
error_missing_end # Output is duplicated somehow. Look for: puts @body or puts @main.body
|
73
|
+
error_inc_line_num # Forgot what's wrong here
|
75
74
|
|
76
75
|
# functions
|
77
76
|
|
78
77
|
functions #
|
78
|
+
more_functions #
|
79
79
|
|
80
80
|
# More/misc...
|
81
81
|
|
data/test/snapshots.rb
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
require 'simplecov' # These two lines must go first
|
2
|
+
SimpleCov.use_merging(true)
|
3
|
+
SimpleCov.start do
|
4
|
+
puts "SimpleCov: Snapshots"
|
5
|
+
add_filter "/test/"
|
6
|
+
enable_coverage :branch
|
7
|
+
primary_coverage :branch
|
8
|
+
end
|
9
|
+
|
1
10
|
require 'minitest/autorun'
|
2
11
|
|
3
12
|
require_relative '../lib/livetext'
|
@@ -7,10 +16,10 @@ Snapshots...
|
|
7
16
|
|
8
17
|
NOTE that the external_files method has been replaced by the Snapshot class.
|
9
18
|
|
10
|
-
You can add any ordinary test method above. But so far, most of these tests simply
|
19
|
+
You can add any ordinary test method above. But so far, most of these tests simply
|
11
20
|
call Snapshot.new
|
12
21
|
|
13
|
-
It works this way:
|
22
|
+
It works this way:
|
14
23
|
- If the test (caller) method is test_my_silly_feature, then we will
|
15
24
|
look for a directory called snapshots/my_silly_feature
|
16
25
|
- In here, there must be a source.lt3
|
@@ -20,12 +29,12 @@ It works this way:
|
|
20
29
|
- The expected-* files are "literal" data
|
21
30
|
* compared byte-for-byte
|
22
31
|
* watch spaces and bad regexes, etc. #duh
|
23
|
-
* each of these files corresponds to a single assertion
|
24
|
-
- A match-* file has two entries per line:
|
32
|
+
* each of these files corresponds to a single assertion
|
33
|
+
- A match-* file has two entries per line:
|
25
34
|
* a ONE-BASED line number (in actual-* file)
|
26
35
|
* a String OR a Regexp (to match against that line)
|
27
36
|
* If there is nonsense here, it currently isn't caught
|
28
|
-
* each of these files MAY correspond to many assertions
|
37
|
+
* each of these files MAY correspond to many assertions
|
29
38
|
- We run livetext on the source and compare actual vs expected (stdout, stderr)
|
30
39
|
- The error output gets checked first (expected or match), THEN standard output
|
31
40
|
- Of course, both must compare correctly for the test to pass
|
@@ -45,8 +54,8 @@ class TestingLivetext < MiniTest::Test
|
|
45
54
|
|
46
55
|
TTY = File.open("/dev/tty","w")
|
47
56
|
|
48
|
-
def self.get_dir # FIXME - uh what?
|
49
|
-
cmdline = ARGV.first == "cmdline"
|
57
|
+
def self.get_dir # FIXME - uh what? remove this??
|
58
|
+
cmdline = ARGV.first == "cmdline"
|
50
59
|
if cmdline
|
51
60
|
dir = "../"
|
52
61
|
Dir.chdir `livetext --path`.chomp.chomp
|
@@ -55,17 +64,24 @@ class TestingLivetext < MiniTest::Test
|
|
55
64
|
end
|
56
65
|
end
|
57
66
|
|
58
|
-
|
59
|
-
|
67
|
+
Args = ARGV - ["cmdline"]
|
60
68
|
dir = self.get_dir
|
61
|
-
|
62
69
|
Data = "#{dir}test/snapshots"
|
63
70
|
Dir.chdir(Data)
|
64
|
-
|
65
71
|
TestDirs = Dir.entries(".").reject {|fname| ! File.directory?(fname) } - %w[. ..]
|
66
72
|
|
73
|
+
Specified = []
|
74
|
+
Args.each do |name|
|
75
|
+
which = TestDirs.select {|tdir| Regexp.new(name) =~ tdir }
|
76
|
+
which.each {|item| Specified << item }
|
77
|
+
end
|
78
|
+
Specified.uniq!
|
67
79
|
|
68
80
|
def self.filter
|
81
|
+
unless Args.empty?
|
82
|
+
puts "Running: #{Args.map {|arg| "/#{arg}/" }}"
|
83
|
+
return Args
|
84
|
+
end
|
69
85
|
all = Dir.entries(".").reject {|fname| ! File.directory?(fname) } - %w[. ..]
|
70
86
|
@included, @excluded = all, []
|
71
87
|
@reasons = []
|
@@ -105,7 +121,7 @@ class TestingLivetext < MiniTest::Test
|
|
105
121
|
end
|
106
122
|
unless @excluded.empty?
|
107
123
|
puts "\nExcluded:\n "
|
108
|
-
@excluded.each.with_index do |name, num|
|
124
|
+
@excluded.each.with_index do |name, num|
|
109
125
|
printf " %-20s %s\n", name, @reasons[num]
|
110
126
|
end
|
111
127
|
puts
|
@@ -191,7 +207,8 @@ class TestingLivetext < MiniTest::Test
|
|
191
207
|
end
|
192
208
|
end
|
193
209
|
|
194
|
-
Subset = Snapshot
|
210
|
+
Subset = Specified = Snapshot::Specified
|
211
|
+
Subset.replace(Snapshot.filter) if Specified.empty?
|
195
212
|
|
196
213
|
Subset.each do |tdir|
|
197
214
|
define_method("test_#{tdir}") do
|