livetext 0.9.19 → 0.9.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.lt3 +4 -2
- data/README.md +330 -339
- data/bin/livetext +0 -2
- data/imports/bookish.rb +8 -10
- data/imports/markdown.rb +6 -6
- data/imports/pyggish.rb +2 -34
- data/imports/tutorial.rb +4 -4
- data/lib/cmdargs.rb +30 -20
- data/lib/errors.rb +2 -0
- data/lib/formatline.rb +54 -124
- data/lib/funcall.rb +93 -0
- data/lib/functions.rb +17 -2
- data/lib/global_helpers.rb +39 -0
- data/lib/handler/import.rb +44 -0
- data/lib/handler.rb +3 -1
- data/lib/helpers.rb +46 -12
- data/lib/html.rb +2 -0
- data/lib/livetext.rb +34 -6
- data/lib/parser/file.rb +0 -2
- data/lib/parser/general.rb +1 -4
- data/lib/parser/mixin.rb +4 -8
- data/lib/parser/set.rb +3 -8
- data/lib/parser/string.rb +11 -10
- data/lib/parser.rb +2 -0
- data/lib/parsing.rb +31 -0
- data/lib/processor.rb +66 -60
- data/lib/standard.rb +28 -17
- data/lib/userapi.rb +8 -4
- data/plugin/bookish.rb +4 -5
- data/plugin/markdown.rb +6 -6
- data/plugin/pyggish.rb +46 -77
- data/plugin/tutorial.rb +3 -3
- data/test/snapshots/error_inc_line_num/OUT +17 -0
- data/test/snapshots/{icanhaz2/expected-error.txt → error_inc_line_num/actual-error.txt} +0 -0
- data/test/snapshots/error_inc_line_num/actual-output.txt +17 -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/out-sdiff.txt +6 -0
- 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/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_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 +13 -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/{icanhaz → import}/expected-output.txt +0 -0
- data/test/snapshots/{icanhaz → import}/match-error.txt +0 -0
- data/test/snapshots/{icanhaz → import}/simple_import.rb +0 -0
- data/test/snapshots/{icanhaz → import}/source.lt3 +2 -2
- data/test/snapshots/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} +0 -0
- 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/simple_import/expected-output.txt +2 -0
- data/test/snapshots/simple_import/source.lt3 +3 -1
- data/test/snapshots/subset.txt +84 -0
- data/test/snapshots.rb +39 -43
- data/test/unit/formatline.rb +253 -134
- data/test/unit/html.rb +1 -1
- data/test/unit/parser/general.rb +1 -2
- data/test/unit/parser/mixin.rb +1 -3
- data/test/unit/parser/set.rb +22 -24
- data/test/unit/parser/string.rb +46 -7
- data/test/unit/parser.rb +0 -1
- data/test/unit/standard.rb +0 -1
- metadata +43 -24
- data/imports/markdown_importable.rb +0 -46
- data/lib/handler/icanhaz.rb +0 -35
- data/lib/livetext/importable.rb +0 -2
- data/lib/parser/import.rb +0 -15
- data/test/affirm/kbks.jpg +0 -0
- data/test/affirm/lm-kbks.lt +0 -19
- data/test/cleanup +0 -1
- data/test/newtest +0 -14
- data/test/sdtest +0 -6
- data/test/snapshots/OMIT.txt +0 -11
- data/test/snapshots/clusion.txt +0 -84
- data/test/snapshots/crap +0 -16
- data/test/snapshots/fixit +0 -6
- data/test/snapshots/icanhaz2/source.lt3 +0 -6
- data/test/unit/parser/importable.rb +0 -19
@@ -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
@@ -0,0 +1,84 @@
|
|
1
|
+
h 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
|
+
|
23
|
+
# Others (usually passing):
|
24
|
+
|
25
|
+
# import/include/mixin, others...
|
26
|
+
|
27
|
+
x error_no_such_inc # Output BEFORE error doesn't get passed through ("leading" output)
|
28
|
+
x error_no_such_copy # ^ Same behavior as error_no_such_inc
|
29
|
+
x error_no_such_mixin # ^ Same behavior as error_missing_end
|
30
|
+
simple_copy #
|
31
|
+
simple_import #
|
32
|
+
simple_include #
|
33
|
+
simple_mixin #
|
34
|
+
x import # "Leading" output doesn't get generated (same as error_no_such_inc)
|
35
|
+
import2 #
|
36
|
+
mixin_bookish #
|
37
|
+
import_bookish #
|
38
|
+
|
39
|
+
# raw input
|
40
|
+
|
41
|
+
single_raw_line #
|
42
|
+
raw_lines #
|
43
|
+
raw_text_block #
|
44
|
+
copy_is_raw #
|
45
|
+
|
46
|
+
# comments
|
47
|
+
|
48
|
+
block_comment #
|
49
|
+
comments_ignored_1 #
|
50
|
+
|
51
|
+
# variables and heredocs
|
52
|
+
|
53
|
+
predef_vars #
|
54
|
+
simple_vars #
|
55
|
+
more_complex_vars #
|
56
|
+
table_with_heredocs #
|
57
|
+
|
58
|
+
# testing def
|
59
|
+
|
60
|
+
def_method #
|
61
|
+
|
62
|
+
# intraline formatting
|
63
|
+
|
64
|
+
basic_formatting #
|
65
|
+
|
66
|
+
# Errors
|
67
|
+
|
68
|
+
error_line_num #
|
69
|
+
error_mismatched_end #
|
70
|
+
error_name_not_permitted #
|
71
|
+
x error_invalid_name # ^ Same behavior as error_no_such_inc
|
72
|
+
x error_missing_end # Output is duplicated somehow. Look for: puts @body or puts @main.body
|
73
|
+
x error_inc_line_num # Forgot what's wrong here
|
74
|
+
|
75
|
+
# functions
|
76
|
+
|
77
|
+
functions #
|
78
|
+
more_functions #
|
79
|
+
|
80
|
+
# More/misc...
|
81
|
+
|
82
|
+
example_alpha #
|
83
|
+
example_alpha2 #
|
84
|
+
hello_world #
|
data/test/snapshots.rb
CHANGED
@@ -45,8 +45,8 @@ class TestingLivetext < MiniTest::Test
|
|
45
45
|
|
46
46
|
TTY = File.open("/dev/tty","w")
|
47
47
|
|
48
|
-
def self.get_dir # FIXME - uh what?
|
49
|
-
cmdline = ARGV.first == "cmdline"
|
48
|
+
def self.get_dir # FIXME - uh what? remove this??
|
49
|
+
cmdline = ARGV.first == "cmdline"
|
50
50
|
if cmdline
|
51
51
|
dir = "../"
|
52
52
|
Dir.chdir `livetext --path`.chomp.chomp
|
@@ -55,24 +55,34 @@ class TestingLivetext < MiniTest::Test
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
|
-
|
58
|
+
Args = ARGV - ["cmdline"]
|
60
59
|
dir = self.get_dir
|
61
|
-
|
62
60
|
Data = "#{dir}test/snapshots"
|
63
61
|
Dir.chdir(Data)
|
64
|
-
|
65
62
|
TestDirs = Dir.entries(".").reject {|fname| ! File.directory?(fname) } - %w[. ..]
|
66
63
|
|
64
|
+
Specified = []
|
65
|
+
Args.each do |name|
|
66
|
+
which = TestDirs.select {|tdir| Regexp.new(name) =~ tdir }
|
67
|
+
which.each {|item| Specified << item }
|
68
|
+
end
|
69
|
+
Specified.uniq!
|
67
70
|
|
68
|
-
def self.filter
|
69
|
-
|
70
|
-
|
71
|
+
def self.filter
|
72
|
+
unless Args.empty?
|
73
|
+
puts "Running: #{Args.map {|arg| "/#{arg}/" }}"
|
74
|
+
return Args
|
75
|
+
end
|
76
|
+
all = Dir.entries(".").reject {|fname| ! File.directory?(fname) } - %w[. ..]
|
77
|
+
@included, @excluded = all, []
|
78
|
+
@reasons = []
|
71
79
|
@iflag, @eflag = true, false # defaults to INCLUDE
|
72
|
-
control = File.new("
|
73
|
-
control.each_line do |
|
80
|
+
control = File.new("subset.txt")
|
81
|
+
control.each_line do |raw_line|
|
82
|
+
line = raw_line.dup
|
74
83
|
line.sub!(/#.*/, "")
|
75
84
|
line.strip!
|
85
|
+
line.chomp!
|
76
86
|
lower = line.downcase
|
77
87
|
dejavu = false
|
78
88
|
case
|
@@ -84,28 +94,32 @@ class TestingLivetext < MiniTest::Test
|
|
84
94
|
dejavu = true
|
85
95
|
when lower == "default exclude all"
|
86
96
|
raise "Only one 'default' allowed" if dejavu
|
97
|
+
@included = []
|
87
98
|
@iflag, @eflag = false, true
|
88
99
|
dejavu = true
|
89
100
|
when lower == "quit"
|
90
101
|
break
|
91
|
-
when lower[0] == "i"
|
102
|
+
when lower[0] == "i" && lower[1] == " "
|
92
103
|
TTY.puts "Warning: Can't include with 'i' when that is default" if @iflag
|
93
|
-
|
94
|
-
|
104
|
+
val = raw_line.split(" ", 2)[1]
|
105
|
+
@included << val unless val.nil? # add to @included
|
106
|
+
when lower[0] == "x" && lower[1] == " "
|
95
107
|
TTY.puts "Warning: Can't exclude with 'x' when that is default" if @eflag
|
96
|
-
|
97
|
-
# add to excluded
|
108
|
+
val, why = raw_line.split(" ", 3).values_at(1, 2)
|
109
|
+
@excluded << val unless val.nil? # add to @excluded
|
110
|
+
@reasons << why.chomp
|
98
111
|
end
|
99
|
-
[included, excluded]
|
100
112
|
end
|
113
|
+
unless @excluded.empty?
|
114
|
+
puts "\nExcluded:\n "
|
115
|
+
@excluded.each.with_index do |name, num|
|
116
|
+
printf " %-20s %s\n", name, @reasons[num]
|
117
|
+
end
|
118
|
+
puts
|
119
|
+
end
|
120
|
+
@included - @excluded
|
101
121
|
end
|
102
122
|
|
103
|
-
i, e = self.filter
|
104
|
-
p i
|
105
|
-
p e
|
106
|
-
|
107
|
-
exit
|
108
|
-
|
109
123
|
def initialize(base, assertion = nil)
|
110
124
|
@assertion = assertion
|
111
125
|
@base = base
|
@@ -184,26 +198,8 @@ class TestingLivetext < MiniTest::Test
|
|
184
198
|
end
|
185
199
|
end
|
186
200
|
|
187
|
-
|
188
|
-
|
189
|
-
omitfile = "OMIT.txt"
|
190
|
-
omitted = File.readlines(omitfile).map(&:chomp)
|
191
|
-
omitted.reject! {|line| line.start_with?("#") }
|
192
|
-
omit_names = omitted.map {|line| line.split.first }
|
193
|
-
STDERR.puts
|
194
|
-
STDERR.puts " >>> Warning: Omitting #{omitted.size} snapshot tests:\n "
|
195
|
-
indented = " "*7
|
196
|
-
omitted.each do |line|
|
197
|
-
STDERR.print indented
|
198
|
-
name, info = line.split(" ", 2)
|
199
|
-
STDERR.printf "%-20s %s\n", name, info
|
200
|
-
end
|
201
|
-
STDERR.puts
|
202
|
-
wanted = selected.empty? ? TestDirs : selected
|
203
|
-
Subset = wanted - omit_names
|
204
|
-
else
|
205
|
-
Subset = args
|
206
|
-
end
|
201
|
+
Subset = Specified = Snapshot::Specified
|
202
|
+
Subset.replace(Snapshot.filter) if Specified.empty?
|
207
203
|
|
208
204
|
Subset.each do |tdir|
|
209
205
|
define_method("test_#{tdir}") do
|