gloo 7.1.3 → 7.3
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.
- checksums.yaml +4 -4
- data/Rakefile +23 -0
- data/docs/application.md +65 -4
- data/docs/development.md +10 -0
- data/docs/iterators.md +66 -1
- data/docs/language_objects.md +34 -22
- data/docs/language_scripting.md +23 -2
- data/docs/language_syntax.md +86 -3
- data/docs/objects.md +6 -6
- data/docs/operators.md +36 -2
- data/docs/plugins.md +26 -0
- data/docs/testing.md +35 -9
- data/docs/verbs.md +31 -3
- data/lib/VERSION +1 -1
- data/lib/VERSION_NOTES +23 -0
- data/lib/dependencies.rb +4 -1
- data/lib/gloo/app/engine.rb +151 -23
- data/lib/gloo/app/prompt.rb +8 -0
- data/lib/gloo/convert/string_to_decimal.rb +3 -6
- data/lib/gloo/convert/string_to_integer.rb +3 -2
- data/lib/gloo/core/dictionary.rb +23 -12
- data/lib/gloo/core/obj.rb +77 -23
- data/lib/gloo/core/op.rb +99 -0
- data/lib/gloo/core/parser.rb +15 -0
- data/lib/gloo/core/tokens.rb +18 -0
- data/lib/gloo/core/verb.rb +130 -1
- data/lib/gloo/exec/dispatch.rb +7 -3
- data/lib/gloo/exec/runaway_recursion.rb +34 -0
- data/lib/gloo/exec/runner.rb +46 -0
- data/lib/gloo/exec/script.rb +16 -2
- data/lib/gloo/expr/expression.rb +77 -6
- data/lib/gloo/expr/l_decimal.rb +18 -2
- data/lib/gloo/expr/l_integer.rb +5 -2
- data/lib/gloo/expr/op_div.rb +4 -0
- data/lib/gloo/expr/op_eq.rb +4 -0
- data/lib/gloo/expr/op_gt.rb +4 -0
- data/lib/gloo/expr/op_gteq.rb +4 -0
- data/lib/gloo/expr/op_ineq.rb +4 -0
- data/lib/gloo/expr/op_lt.rb +4 -0
- data/lib/gloo/expr/op_lteq.rb +4 -0
- data/lib/gloo/expr/op_minus.rb +4 -0
- data/lib/gloo/expr/op_mult.rb +3 -7
- data/lib/gloo/expr/op_plus.rb +8 -1
- data/lib/gloo/objs/basic/alias.rb +6 -1
- data/lib/gloo/objs/basic/boolean.rb +15 -6
- data/lib/gloo/objs/basic/decimal.rb +25 -3
- data/lib/gloo/objs/basic/script.rb +3 -24
- data/lib/gloo/objs/basic/string_msgs.rb +50 -68
- data/lib/gloo/objs/ctrl/until.rb +219 -0
- data/lib/gloo/persist/declaration_ledger.rb +9 -9
- data/lib/gloo/persist/declaration_writer.rb +208 -0
- data/lib/gloo/persist/disc_mech.rb +70 -39
- data/lib/gloo/persist/file_loader.rb +125 -66
- data/lib/gloo/persist/file_saver.rb +130 -198
- data/lib/gloo/persist/file_storage.rb +15 -4
- data/lib/gloo/persist/file_style.rb +89 -0
- data/lib/gloo/persist/line_splitter.rb +16 -1
- data/lib/gloo/persist/persist_man.rb +112 -30
- data/lib/gloo/persist/save_index.rb +211 -0
- data/lib/gloo/persist/script_body_collector.rb +16 -21
- data/lib/gloo/persist/source/blank_node.rb +10 -3
- data/lib/gloo/persist/source/comment_node.rb +10 -2
- data/lib/gloo/persist/source/directive_node.rb +10 -2
- data/lib/gloo/persist/source/obj_node.rb +174 -9
- data/lib/gloo/persist/source/source_doc.rb +54 -0
- data/lib/gloo/persist/subtree_extractor.rb +9 -37
- data/lib/gloo/persist/trivia_buffer.rb +7 -7
- data/lib/gloo/plugin/callback.rb +54 -10
- data/lib/gloo/plugin/ext_manager.rb +44 -0
- data/lib/gloo/plugin/lib_manager.rb +65 -1
- data/lib/gloo/shell/runner.rb +36 -9
- data/lib/gloo/verbs/break.rb +6 -4
- data/lib/gloo/verbs/check.rb +8 -2
- data/lib/gloo/verbs/create.rb +13 -4
- data/lib/gloo/verbs/if.rb +33 -10
- data/lib/gloo/verbs/invoke.rb +6 -1
- data/lib/gloo/verbs/list.rb +9 -2
- data/lib/gloo/verbs/load.rb +31 -22
- data/lib/gloo/verbs/move.rb +50 -5
- data/lib/gloo/verbs/put.rb +9 -2
- data/lib/gloo/verbs/reload.rb +2 -1
- data/lib/gloo/verbs/run.rb +8 -1
- data/lib/gloo/verbs/save.rb +30 -4
- data/lib/gloo/verbs/tell.rb +9 -2
- data/lib/gloo/verbs/unless.rb +34 -10
- data/lib/gloo/verbs/unload.rb +81 -16
- data/test.gloo/app/exit_status.test.gloo +34 -0
- data/test.gloo/app/fixtures/exit_after_error.gloo +9 -0
- data/test.gloo/ctrl/until.test.gloo +100 -0
- data/test.gloo/lang/computed_paths.test.gloo +98 -0
- data/test.gloo/lang/declaration.test.gloo +36 -0
- data/test.gloo/lang/fixtures/mixed_indent.gloo +5 -0
- data/test.gloo/lang/literal.test.gloo +43 -0
- data/test.gloo/lang/naming.test.gloo +44 -6
- data/test.gloo/lang/ops.test.gloo +193 -0
- data/test.gloo/lang/runaway_recursion.test.gloo +44 -0
- data/test.gloo/objs/decimal.test.gloo +23 -0
- data/test.gloo/objs/string.test.gloo +30 -0
- data/test.gloo/verbs/create.test.gloo +6 -21
- data/test.gloo/verbs/fixtures/load_beside.gloo +6 -0
- data/test.gloo/verbs/fixtures/lossless_text.gloo +7 -0
- data/test.gloo/verbs/fixtures/lossless_text_saved.gloo +9 -0
- data/test.gloo/verbs/if.test.gloo +41 -0
- data/test.gloo/verbs/load.test.gloo +22 -3
- data/test.gloo/verbs/move.test.gloo +39 -0
- data/test.gloo/verbs/save.test.gloo +239 -0
- data/test.gloo/verbs/unless.test.gloo +40 -0
- data/test.gloo/verbs/unload.test.gloo +61 -3
- metadata +15 -1
|
@@ -7,6 +7,8 @@ tests.lang.ops [can] :
|
|
|
7
7
|
first [string] : Ada
|
|
8
8
|
last [string] : Lovelace
|
|
9
9
|
full [string] :
|
|
10
|
+
count [int] : 3
|
|
11
|
+
five [string] : 5
|
|
10
12
|
|
|
11
13
|
confirm_eq_ops [test] :
|
|
12
14
|
description [string] : Confirm equality operations.
|
|
@@ -105,3 +107,194 @@ tests.lang.ops [can] :
|
|
|
105
107
|
eval ^^.full = 'abcd'
|
|
106
108
|
assert "expected no operator, + and and to mix"
|
|
107
109
|
|
|
110
|
+
|
|
111
|
+
confirm_integer_and_decimal_math [test] :
|
|
112
|
+
description [string] : An integer and a decimal give a decimal, whichever side each is on.
|
|
113
|
+
on_test [script] :
|
|
114
|
+
eval 1 + 2.5 = 3.5
|
|
115
|
+
assert "expected 1 + 2.5 to be 3.5"
|
|
116
|
+
|
|
117
|
+
eval 1 - 0.5 = 0.5
|
|
118
|
+
assert "expected 1 - 0.5 to be 0.5"
|
|
119
|
+
|
|
120
|
+
eval 3 * 1.5 = 4.5
|
|
121
|
+
assert "expected 3 * 1.5 to be 4.5"
|
|
122
|
+
|
|
123
|
+
eval 7 / 2.0 = 3.5
|
|
124
|
+
assert "expected 7 / 2.0 to be 3.5"
|
|
125
|
+
|
|
126
|
+
eval 2.5 + 1 = 3.5
|
|
127
|
+
assert "expected 2.5 + 1 to be 3.5"
|
|
128
|
+
|
|
129
|
+
confirm_two_integers_stay_integers [test] :
|
|
130
|
+
description [string] : An integer with an integer gives an integer.
|
|
131
|
+
on_test [script] :
|
|
132
|
+
eval 7 / 2 = 3
|
|
133
|
+
assert "expected 7 / 2 to be 3"
|
|
134
|
+
|
|
135
|
+
confirm_integer_and_decimal_compare [test] :
|
|
136
|
+
description [string] : An integer on the left is compared with a decimal as a decimal.
|
|
137
|
+
on_test [script] :
|
|
138
|
+
eval 1 = 1.9
|
|
139
|
+
refute "expected 1 to not equal 1.9"
|
|
140
|
+
|
|
141
|
+
eval 1 != 1.9
|
|
142
|
+
assert "expected 1 != 1.9"
|
|
143
|
+
|
|
144
|
+
eval 1 < 1.5
|
|
145
|
+
assert "expected 1 < 1.5"
|
|
146
|
+
|
|
147
|
+
eval 2 > 1.5
|
|
148
|
+
assert "expected 2 > 1.5"
|
|
149
|
+
|
|
150
|
+
eval 1 <= 0.5
|
|
151
|
+
refute "expected 1 to not be less than or equal to 0.5"
|
|
152
|
+
|
|
153
|
+
eval 1 >= 1.5
|
|
154
|
+
refute "expected 1 to not be greater than or equal to 1.5"
|
|
155
|
+
|
|
156
|
+
confirm_text_less_than [test] :
|
|
157
|
+
description [string] : Text is compared in dictionary order with < and <=.
|
|
158
|
+
on_test [script] :
|
|
159
|
+
eval 'abc' < 'abd'
|
|
160
|
+
assert "expected 'abc' < 'abd'"
|
|
161
|
+
|
|
162
|
+
eval 'B' < 'a'
|
|
163
|
+
refute "expected 'B' to not be less than 'a'"
|
|
164
|
+
|
|
165
|
+
eval 'A' < 'a'
|
|
166
|
+
assert "expected 'A' < 'a' (capital first on a tie)"
|
|
167
|
+
|
|
168
|
+
eval 'apple' < 'Banana'
|
|
169
|
+
assert "expected 'apple' < 'Banana'"
|
|
170
|
+
|
|
171
|
+
eval 'x' <= 'x'
|
|
172
|
+
assert "expected 'x' <= 'x'"
|
|
173
|
+
|
|
174
|
+
eval 'abd' <= 'abc'
|
|
175
|
+
refute "expected 'abd' to not be less than or equal to 'abc'"
|
|
176
|
+
|
|
177
|
+
confirm_text_greater_than [test] :
|
|
178
|
+
description [string] : Text is compared in dictionary order with > and >=.
|
|
179
|
+
on_test [script] :
|
|
180
|
+
eval 'abd' > 'abc'
|
|
181
|
+
assert "expected 'abd' > 'abc'"
|
|
182
|
+
|
|
183
|
+
eval 'b' > 'A'
|
|
184
|
+
assert "expected 'b' > 'A'"
|
|
185
|
+
|
|
186
|
+
eval 'x' > 'x'
|
|
187
|
+
refute "expected 'x' to not be greater than 'x'"
|
|
188
|
+
|
|
189
|
+
eval 'x' >= 'x'
|
|
190
|
+
assert "expected 'x' >= 'x'"
|
|
191
|
+
|
|
192
|
+
eval 'A' >= 'a'
|
|
193
|
+
refute "expected 'A' to not be greater than or equal to 'a'"
|
|
194
|
+
|
|
195
|
+
confirm_text_equal_stays_exact [test] :
|
|
196
|
+
description [string] : = still tells capitals apart.
|
|
197
|
+
on_test [script] :
|
|
198
|
+
eval 'x' = 'X'
|
|
199
|
+
refute "expected 'x' to not equal 'X'"
|
|
200
|
+
|
|
201
|
+
confirm_number_and_text_join [test] :
|
|
202
|
+
description [string] : + with text on either side joins, as text.
|
|
203
|
+
on_test [script] :
|
|
204
|
+
put ^^.count ' items' into ^^.full
|
|
205
|
+
eval ^^.full = '3 items'
|
|
206
|
+
assert "expected count ' items' to be '3 items'"
|
|
207
|
+
|
|
208
|
+
put ^^.count and ' items' into ^^.full
|
|
209
|
+
eval ^^.full = '3 items'
|
|
210
|
+
assert "expected count and ' items' to be '3 items'"
|
|
211
|
+
|
|
212
|
+
eval 5 + '5' = '55'
|
|
213
|
+
assert "expected 5 + '5' to be '55'"
|
|
214
|
+
|
|
215
|
+
confirm_text_as_number_in_math [test] :
|
|
216
|
+
description [string] : - * and / use text as a number.
|
|
217
|
+
on_test [script] :
|
|
218
|
+
eval 10 - ^^.five = 5
|
|
219
|
+
assert "expected 10 - five to be 5"
|
|
220
|
+
|
|
221
|
+
eval '3' * 2 = 6
|
|
222
|
+
assert "expected '3' * 2 to be 6"
|
|
223
|
+
|
|
224
|
+
eval '7.0' / 2 = 3.5
|
|
225
|
+
assert "expected '7.0' / 2 to be 3.5"
|
|
226
|
+
|
|
227
|
+
confirm_text_not_a_number_is_zero [test] :
|
|
228
|
+
description [string] : Text that isn't a number is 0 in math, with a warning.
|
|
229
|
+
expect_errors [bool] : true
|
|
230
|
+
on_test [script] :
|
|
231
|
+
eval 1 - 'a' = 1
|
|
232
|
+
assert "expected 1 - 'a' to be 1"
|
|
233
|
+
|
|
234
|
+
confirm_number_and_text_compare [test] :
|
|
235
|
+
description [string] : A number and text that holds a number compare as numbers.
|
|
236
|
+
on_test [script] :
|
|
237
|
+
eval '5' < 10
|
|
238
|
+
assert "expected '5' < 10"
|
|
239
|
+
|
|
240
|
+
eval 3 = '3'
|
|
241
|
+
assert "expected 3 = '3'"
|
|
242
|
+
|
|
243
|
+
eval ^^.five = 5
|
|
244
|
+
assert "expected five = 5"
|
|
245
|
+
|
|
246
|
+
eval 3 = 'abc'
|
|
247
|
+
refute "expected 3 to not equal 'abc'"
|
|
248
|
+
|
|
249
|
+
confirm_grouping [test] :
|
|
250
|
+
description [string] : A group in parentheses is worked out first.
|
|
251
|
+
on_test [script] :
|
|
252
|
+
eval 2 * ( 3 + 4 ) = 14
|
|
253
|
+
assert "expected 2 * ( 3 + 4 ) to be 14"
|
|
254
|
+
|
|
255
|
+
eval ( 1 + 2 ) * 3 = 9
|
|
256
|
+
assert "expected ( 1 + 2 ) * 3 to be 9"
|
|
257
|
+
|
|
258
|
+
eval ( 3 + 4 )
|
|
259
|
+
eval it = 7
|
|
260
|
+
assert "expected ( 3 + 4 ) to be 7"
|
|
261
|
+
|
|
262
|
+
confirm_groups_nest [test] :
|
|
263
|
+
description [string] : Groups nest to any depth.
|
|
264
|
+
on_test [script] :
|
|
265
|
+
eval 2 * ( 3 * ( 1 + 1 ) ) = 12
|
|
266
|
+
assert "expected 2 * ( 3 * ( 1 + 1 ) ) to be 12"
|
|
267
|
+
|
|
268
|
+
eval ((1 + 2) * (3 + 4)) = 21
|
|
269
|
+
assert "expected ((1 + 2) * (3 + 4)) to be 21"
|
|
270
|
+
|
|
271
|
+
confirm_no_precedence [test] :
|
|
272
|
+
description [string] : Without a group, still strictly left to right.
|
|
273
|
+
on_test [script] :
|
|
274
|
+
eval 2 + 3 * 4 = 20
|
|
275
|
+
assert "expected 2 + 3 * 4 to be 20"
|
|
276
|
+
|
|
277
|
+
eval 2 + ( 3 * 4 ) = 14
|
|
278
|
+
assert "expected 2 + ( 3 * 4 ) to be 14"
|
|
279
|
+
|
|
280
|
+
confirm_quoted_parens_are_text [test] :
|
|
281
|
+
description [string] : Parentheses inside quotes are text.
|
|
282
|
+
on_test [script] :
|
|
283
|
+
put 'a (b)' into ^^.full
|
|
284
|
+
eval ^^.full = 'a (b)'
|
|
285
|
+
assert "expected 'a (b)' to stay as text"
|
|
286
|
+
|
|
287
|
+
confirm_grouping_in_put_and_if [test] :
|
|
288
|
+
description [string] : Groups work in put and in an if's condition and then part.
|
|
289
|
+
on_test [script] :
|
|
290
|
+
put ( 1 + 2 ) * ^^.count into ^^.full
|
|
291
|
+
eval ^^.full = '9'
|
|
292
|
+
assert "expected ( 1 + 2 ) * count to be 9"
|
|
293
|
+
|
|
294
|
+
if ( ^^.count = 3 ) then put 'yes' into ^^.full
|
|
295
|
+
eval ^^.full = 'yes'
|
|
296
|
+
assert "expected a group in the condition"
|
|
297
|
+
|
|
298
|
+
if true then put 2 * ( 1 + 1 ) into ^^.full
|
|
299
|
+
eval ^^.full = '4'
|
|
300
|
+
assert "expected a group in the then part"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Runaway recursion: a script that runs itself with no end is reported
|
|
3
|
+
# as an error, once, and the run carries on.
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
tests.lang.runaway_recursion [can] :
|
|
7
|
+
|
|
8
|
+
n [int] : 0
|
|
9
|
+
after [int] : 0
|
|
10
|
+
errs [int] : 0
|
|
11
|
+
|
|
12
|
+
again [script] :
|
|
13
|
+
tell ^.n to inc
|
|
14
|
+
run ^.again
|
|
15
|
+
tell ^.after to inc
|
|
16
|
+
|
|
17
|
+
f [ƒ] :
|
|
18
|
+
on_invoke [script] : invoke ^^.f
|
|
19
|
+
|
|
20
|
+
is_reported_and_the_test_carries_on [test] :
|
|
21
|
+
description [string] : A script that runs itself is stopped with an error, it is false, and the next line runs.
|
|
22
|
+
expect_errors [bool] : true
|
|
23
|
+
on_test [script] :
|
|
24
|
+
put 0 into ^^.n
|
|
25
|
+
run ^^.again
|
|
26
|
+
refute "expected it to be false"
|
|
27
|
+
eval ^^.n > 100
|
|
28
|
+
assert "expected the script to have run itself many times first"
|
|
29
|
+
|
|
30
|
+
unwinds_the_whole_run [test] :
|
|
31
|
+
description [string] : No line after a script's own run runs on the way back up.
|
|
32
|
+
expect_errors [bool] : true
|
|
33
|
+
on_test [script] :
|
|
34
|
+
put 0 into ^^.after
|
|
35
|
+
run ^^.again
|
|
36
|
+
eval ^^.after = 0
|
|
37
|
+
assert "expected no line after the recursive run to run"
|
|
38
|
+
|
|
39
|
+
a_function_invoking_itself [test] :
|
|
40
|
+
description [string] : A function that invokes itself is stopped the same way.
|
|
41
|
+
expect_errors [bool] : true
|
|
42
|
+
on_test [script] :
|
|
43
|
+
invoke ^^.f
|
|
44
|
+
refute "expected it to be false"
|
|
@@ -34,3 +34,26 @@ tests.objs.decimal [can] :
|
|
|
34
34
|
tell ^.f to format ('%.2f')
|
|
35
35
|
eval it = '3.14'
|
|
36
36
|
assert "expected formatted decimal to match"
|
|
37
|
+
|
|
38
|
+
format_agrees_with_round [test] :
|
|
39
|
+
description [string] : format rounds first, as round does.
|
|
40
|
+
f [decimal] :
|
|
41
|
+
on_test [script] :
|
|
42
|
+
put 1.005 into ^.f
|
|
43
|
+
tell ^.f to format ('%.2f')
|
|
44
|
+
eval it = '1.01'
|
|
45
|
+
assert "expected '%.2f' of 1.005 to be 1.01, as round gives"
|
|
46
|
+
|
|
47
|
+
put 2.5 into ^.f
|
|
48
|
+
tell ^.f to format ('%.0f')
|
|
49
|
+
eval it = '3'
|
|
50
|
+
assert "expected '%.0f' of 2.5 to round half away from zero"
|
|
51
|
+
|
|
52
|
+
round_halves_away_from_zero [test] :
|
|
53
|
+
description [string] : round takes a half away from zero.
|
|
54
|
+
f [decimal] :
|
|
55
|
+
on_test [script] :
|
|
56
|
+
put -2.5 into ^.f
|
|
57
|
+
tell ^.f to round
|
|
58
|
+
eval ^.f = -3
|
|
59
|
+
assert "expected -2.5 to round to -3"
|
|
@@ -135,3 +135,33 @@ tests.objs.string [can] :
|
|
|
135
135
|
assert "expected dst.3 to equal 'three'"
|
|
136
136
|
eval ^^.s = 'one,two,three'
|
|
137
137
|
assert "expected split_list to leave the string unchanged"
|
|
138
|
+
|
|
139
|
+
sub_with_groups [test] :
|
|
140
|
+
description [string] : A group can be either parameter of sub.
|
|
141
|
+
on_test [script] :
|
|
142
|
+
put 'hello world' into ^^.s
|
|
143
|
+
tell ^^.s to sub ( ( 'w' + 'o' ) 'WO' )
|
|
144
|
+
eval it = 'hello WOrld'
|
|
145
|
+
assert "expected a group as the first parameter"
|
|
146
|
+
|
|
147
|
+
tell ^^.s to sub ( 'l' ( 'x' + 'y' ) )
|
|
148
|
+
eval it = 'hexylo WOrld'
|
|
149
|
+
assert "expected a group as the second parameter"
|
|
150
|
+
|
|
151
|
+
index_of_with_a_group [test] :
|
|
152
|
+
description [string] : A group can be index_of's start position.
|
|
153
|
+
on_test [script] :
|
|
154
|
+
put 'hello world' into ^^.s
|
|
155
|
+
tell ^^.s to index_of ( 'o' ( 2 + 3 ) )
|
|
156
|
+
eval it = 7
|
|
157
|
+
assert "expected the second o"
|
|
158
|
+
|
|
159
|
+
sub_needs_two_params [test] :
|
|
160
|
+
description [string] : sub with one parameter is a syntax error and changes nothing.
|
|
161
|
+
expect_errors [bool] : true
|
|
162
|
+
on_test [script] :
|
|
163
|
+
put 'hello' into ^^.s
|
|
164
|
+
tell ^^.s to sub ( 'l' )
|
|
165
|
+
refute "expected it to be false"
|
|
166
|
+
eval ^^.s = 'hello'
|
|
167
|
+
assert "expected the string unchanged"
|
|
@@ -38,32 +38,17 @@ tests.verbs.create [can] :
|
|
|
38
38
|
|
|
39
39
|
tests.verbs.create_names [can] :
|
|
40
40
|
|
|
41
|
-
err_fired [bool] : false
|
|
42
41
|
list [can] :
|
|
43
42
|
n [int] : 3
|
|
44
|
-
before [int] : 0
|
|
45
43
|
slot [alias] :
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
parenthesised_name_is_an_error [test] :
|
|
51
|
-
description [string] : create doesn't compute a name; a parenthesised one is reported and nothing is created.
|
|
52
|
-
expect_errors [bool] : true
|
|
45
|
+
parenthesised_name_computes_the_name [test] :
|
|
46
|
+
description [string] : create ( expr ) creates the object at the path the expression works out to.
|
|
53
47
|
on_test [script] :
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
eval it = false
|
|
59
|
-
assert "expected it to be false"
|
|
60
|
-
|
|
61
|
-
eval ^^.err_fired = true
|
|
62
|
-
assert "expected a parenthesised name to be an error"
|
|
63
|
-
|
|
64
|
-
tell ^^.list to count
|
|
65
|
-
eval it = ^^.before
|
|
66
|
-
assert "expected nothing to be created"
|
|
48
|
+
create ( 'tests.verbs.create_names.list.p' ^^.n ) as string : made
|
|
49
|
+
eval tests.verbs.create_names.list.p3 = 'made'
|
|
50
|
+
assert "expected the object to be created at the computed path"
|
|
51
|
+
tell tests.verbs.create_names.list.p3 to unload
|
|
67
52
|
|
|
68
53
|
alias_computes_the_name [test] :
|
|
69
54
|
description [string] : The way to create at a computed path: point an alias at it, then create the alias.
|
|
@@ -33,3 +33,44 @@ tests.verbs.if [can] :
|
|
|
33
33
|
eval false
|
|
34
34
|
if false do eval false else eval true
|
|
35
35
|
assert "expected else to run after a 'do' action"
|
|
36
|
+
|
|
37
|
+
#
|
|
38
|
+
# Conditions use the [bool] rule for what counts as true.
|
|
39
|
+
#
|
|
40
|
+
s [string] :
|
|
41
|
+
ran [string] :
|
|
42
|
+
|
|
43
|
+
the_text_true_is_true [test] :
|
|
44
|
+
description [string] : The text 'true' in a condition counts as true.
|
|
45
|
+
on_test [script] :
|
|
46
|
+
put 'true' into ^^.s
|
|
47
|
+
put '' into ^^.ran
|
|
48
|
+
if ^^.s then put 'then' into ^^.ran
|
|
49
|
+
eval ^^.ran = 'then'
|
|
50
|
+
assert "expected the text true to run then"
|
|
51
|
+
|
|
52
|
+
blank_is_false [test] :
|
|
53
|
+
description [string] : A blank value is false, so else runs.
|
|
54
|
+
on_test [script] :
|
|
55
|
+
put '' into ^^.s
|
|
56
|
+
if ^^.s then put 'then' into ^^.ran else put 'else' into ^^.ran
|
|
57
|
+
eval ^^.ran = 'else'
|
|
58
|
+
assert "expected blank to run else"
|
|
59
|
+
|
|
60
|
+
other_text_is_false [test] :
|
|
61
|
+
description [string] : Text that is neither true nor false is false, with a warning.
|
|
62
|
+
expect_errors [bool] : true
|
|
63
|
+
on_test [script] :
|
|
64
|
+
put 'abc' into ^^.s
|
|
65
|
+
if ^^.s then put 'then' into ^^.ran else put 'else' into ^^.ran
|
|
66
|
+
eval ^^.ran = 'else'
|
|
67
|
+
assert "expected other text to run else"
|
|
68
|
+
|
|
69
|
+
failed_condition_runs_neither [test] :
|
|
70
|
+
description [string] : A condition that reports an error abandons the line; else doesn't run.
|
|
71
|
+
expect_errors [bool] : true
|
|
72
|
+
on_test [script] :
|
|
73
|
+
put '' into ^^.ran
|
|
74
|
+
if no.such.obj then put 'then' into ^^.ran else put 'else' into ^^.ran
|
|
75
|
+
eval ^^.ran = ''
|
|
76
|
+
assert "expected neither branch to run"
|
|
@@ -46,9 +46,10 @@ END
|
|
|
46
46
|
load_lib_registers_type [test] :
|
|
47
47
|
description [string] : load lib registers that library's object types.
|
|
48
48
|
on_test [script] :
|
|
49
|
-
#
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
# Start without md, whatever an earlier test or file loaded.
|
|
50
|
+
unload lib md
|
|
51
|
+
exists? object markdown
|
|
52
|
+
refute "markdown type should not be registered after unload"
|
|
52
53
|
|
|
53
54
|
load lib md
|
|
54
55
|
exists? object markdown
|
|
@@ -172,3 +173,21 @@ END
|
|
|
172
173
|
assert "expected the full path without .gloo to load"
|
|
173
174
|
tell computed_demo to unload
|
|
174
175
|
tell ^^.computed_f to delete
|
|
176
|
+
|
|
177
|
+
# A relative name looks next to the loading file first; these scripts
|
|
178
|
+
# are declared in this file, so fixtures/ is the folder beside it.
|
|
179
|
+
load_a_file_beside_this_one [test] :
|
|
180
|
+
description [string] : A relative load finds a file next to the file the script came from.
|
|
181
|
+
on_test [script] :
|
|
182
|
+
load fixtures/load_beside
|
|
183
|
+
eval load_beside_demo.s = 'beside'
|
|
184
|
+
assert "expected fixtures/load_beside.gloo to load from beside this file"
|
|
185
|
+
tell load_beside_demo to unload
|
|
186
|
+
|
|
187
|
+
load_a_prefix_beside_this_one [test] :
|
|
188
|
+
description [string] : A relative wildcard with a file name prefix finds the files next to the loading file.
|
|
189
|
+
on_test [script] :
|
|
190
|
+
load fixtures/load_beside*
|
|
191
|
+
eval load_beside_demo.s = 'beside'
|
|
192
|
+
assert "expected fixtures/load_beside*.gloo to load from beside this file"
|
|
193
|
+
tell load_beside_demo to unload
|
|
@@ -16,3 +16,42 @@ tests.verbs.move [can] :
|
|
|
16
16
|
assert "expected a to be in t"
|
|
17
17
|
exists? instance tests.verbs.move.c.a
|
|
18
18
|
refute "expected a not to be in c"
|
|
19
|
+
|
|
20
|
+
# A name is unique in its container: a move onto a taken name, or
|
|
21
|
+
# inside itself, is refused.
|
|
22
|
+
taken [container] :
|
|
23
|
+
a [string] : moving
|
|
24
|
+
dst [container] :
|
|
25
|
+
a [string] : already here
|
|
26
|
+
outer [container] :
|
|
27
|
+
inner [container] :
|
|
28
|
+
msg [string] :
|
|
29
|
+
|
|
30
|
+
on_error [script] :
|
|
31
|
+
error_data [can] :
|
|
32
|
+
message [string] :
|
|
33
|
+
|
|
34
|
+
moving_onto_a_taken_name_is_refused [test] :
|
|
35
|
+
description [string] : A move into a container with a child of the same name is an error; nothing moves.
|
|
36
|
+
expect_errors [bool] : true
|
|
37
|
+
on_test [script] :
|
|
38
|
+
move ^^.taken.a to ^^.dst
|
|
39
|
+
eval it = false
|
|
40
|
+
assert "expected it to be false"
|
|
41
|
+
eval ^^.dst.a = 'already here'
|
|
42
|
+
assert "expected the child already there to be untouched"
|
|
43
|
+
exists? instance ^^.taken.a
|
|
44
|
+
assert "expected the object not to have moved"
|
|
45
|
+
put ^^.error_data.message into ^^.msg
|
|
46
|
+
check ^^.msg for starts_with? ( 'Could not move' )
|
|
47
|
+
assert "expected a could-not-move error"
|
|
48
|
+
|
|
49
|
+
moving_inside_itself_is_refused [test] :
|
|
50
|
+
description [string] : A move into the object's own child is an error; nothing moves.
|
|
51
|
+
expect_errors [bool] : true
|
|
52
|
+
on_test [script] :
|
|
53
|
+
move ^^.outer to ^^.outer.inner
|
|
54
|
+
eval it = false
|
|
55
|
+
assert "expected it to be false"
|
|
56
|
+
exists? instance ^^.outer.inner
|
|
57
|
+
assert "expected outer to still be in place"
|