testml 0.0.1 → 0.0.2
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/.gemspec +3 -1
- data/CHANGELOG.yaml +4 -1
- data/LICENSE +1 -1
- data/README.rdoc +30 -5
- data/Rakefile +10 -1
- data/ToDo +56 -0
- data/lib/rake/testml.rb +14 -0
- data/lib/testml.rb +46 -2
- data/lib/testml/bridge.rb +5 -0
- data/lib/testml/compiler.rb +106 -0
- data/lib/testml/compiler/lite.rb +194 -0
- data/lib/testml/compiler/pegex.rb +50 -0
- data/lib/testml/compiler/pegex/ast.rb +145 -0
- data/lib/testml/compiler/pegex/grammar.rb +173 -0
- data/lib/testml/library.rb +7 -0
- data/lib/testml/library/debug.rb +18 -0
- data/lib/testml/library/standard.rb +86 -0
- data/lib/testml/runtime.rb +501 -0
- data/lib/testml/runtime/unit.rb +94 -0
- data/lib/testml/setup.rb +65 -0
- data/lib/testml/util.rb +22 -0
- data/test/ast/arguments.tml +87 -0
- data/test/ast/basic.tml +83 -0
- data/test/ast/dataless.tml +36 -0
- data/test/ast/exceptions.tml +59 -0
- data/test/ast/external.tml +42 -0
- data/test/ast/function.tml +276 -0
- data/test/ast/label.tml +58 -0
- data/test/ast/markers.tml +36 -0
- data/test/ast/semicolons.tml +30 -0
- data/test/ast/truth.tml +85 -0
- data/test/ast/types.tml +163 -0
- data/test/compile-lite.rb +38 -0
- data/test/compile-testml-document.rb +59 -0
- data/test/compile.rb +57 -0
- data/test/inline-bridge.rb +30 -0
- data/test/inline.rb +28 -0
- data/test/strings.rb +24 -0
- data/test/testml.rb +38 -0
- data/test/testml.yaml +10 -0
- data/test/testml/arguments.tml +18 -0
- data/test/testml/assertions.tml +15 -0
- data/test/testml/basic.tml +37 -0
- data/test/testml/dataless.tml +9 -0
- data/test/testml/exceptions.tml +16 -0
- data/test/testml/external.tml +8 -0
- data/test/testml/external1.tml +10 -0
- data/test/testml/external2.tml +3 -0
- data/test/testml/function.tml +82 -0
- data/test/testml/label.tml +24 -0
- data/test/testml/markers.tml +19 -0
- data/test/testml/semicolons.tml +10 -0
- data/test/testml/standard.tml +50 -0
- data/test/testml/truth.tml +22 -0
- data/test/testml/types.tml +24 -0
- data/test/testml_bridge.rb +28 -0
- metadata +69 -4
- data/test/fail.rb +0 -12
data/test/testml.yaml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
%TestML 0.1.0
|
2
|
+
|
3
|
+
Plan = 3
|
4
|
+
|
5
|
+
*what.combine(*who) == *greeting
|
6
|
+
*what.combine('and', *else) == *greeting
|
7
|
+
*what.combine('and', *else.uppercase) == *upper_greeting
|
8
|
+
|
9
|
+
=== Dear John
|
10
|
+
--- what: Dear
|
11
|
+
--- who: John
|
12
|
+
--- greeting: Dear John
|
13
|
+
|
14
|
+
=== Greetings and Salutations
|
15
|
+
--- what: Greetings
|
16
|
+
--- else: Salutations
|
17
|
+
--- greeting: Greetings and Salutations
|
18
|
+
--- upper_greeting: Greetings and SALUTATIONS
|
@@ -0,0 +1,15 @@
|
|
1
|
+
%TestML 0.1.0
|
2
|
+
|
3
|
+
Plan = 6
|
4
|
+
|
5
|
+
Label = 'EQ tests'
|
6
|
+
'The cat in the hat'.EQ('The cat in the hat')
|
7
|
+
'The cat in the hat' == 'The cat in the hat'
|
8
|
+
|
9
|
+
Label = 'HAS tests'
|
10
|
+
'The cat in the hat'.HAS('cat')
|
11
|
+
'The cat in the hat' ~~ 'hat'
|
12
|
+
|
13
|
+
Label = 'OK tests'
|
14
|
+
'The cat in the hat'.OK
|
15
|
+
'The cat in the hat'.OK()
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# The TestML version directive is required. Switching to semantic versioning
|
2
|
+
# scheme, for now.
|
3
|
+
|
4
|
+
%TestML 0.1.0
|
5
|
+
|
6
|
+
# The title of the test. Goes into a special global variable. Variables
|
7
|
+
# strating with uppercase letter usually belong to TestML. Title may or may
|
8
|
+
# not be used by a framework, but still nicely self-documenting.
|
9
|
+
Title = 'A Basic TestML File'
|
10
|
+
|
11
|
+
# The Plan global variable indicates the expected number of tests.
|
12
|
+
Plan = 4
|
13
|
+
|
14
|
+
# The bridge class will need to support 'uppercase' and 'lowercase' methods.
|
15
|
+
*text.uppercase == *upper
|
16
|
+
*text.lowercase == *lower
|
17
|
+
*lower.uppercase == *upper.lowercase.uppercase
|
18
|
+
|
19
|
+
|
20
|
+
# Define 2 data blocks. 'Test One' is the block label.
|
21
|
+
=== Test One
|
22
|
+
# This block has 3 inline data points. The data has no newline at the end
|
23
|
+
--- text: I like Pie.
|
24
|
+
--- upper: I LIKE PIE.
|
25
|
+
--- lower: i like pie.
|
26
|
+
|
27
|
+
=== Test Two
|
28
|
+
# This block has no 'upper' point, so will not be used in some tests. These
|
29
|
+
# data points do have trailing newlines.
|
30
|
+
--- text
|
31
|
+
Say it,
|
32
|
+
Don't spray it.
|
33
|
+
|
34
|
+
# The blank line above doesn't count as text.
|
35
|
+
--- lower
|
36
|
+
say it,
|
37
|
+
don't spray it.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
%TestML 0.1.0
|
2
|
+
|
3
|
+
Plan = 2
|
4
|
+
|
5
|
+
Throw(*error).NonExistingMethod.Catch ~~ *match
|
6
|
+
|
7
|
+
message = "blowed up"
|
8
|
+
|
9
|
+
Throw(message).Catch == message
|
10
|
+
|
11
|
+
=== Error message from data
|
12
|
+
--- error
|
13
|
+
O NOES!
|
14
|
+
|
15
|
+
Something went wrong
|
16
|
+
--- match: Something
|
@@ -0,0 +1,82 @@
|
|
1
|
+
%TestML 0.1.0
|
2
|
+
# %DumpAst 1
|
3
|
+
|
4
|
+
Plan = 21
|
5
|
+
|
6
|
+
Label = 'Fruity Tests'
|
7
|
+
|
8
|
+
{
|
9
|
+
Label = 'Anonymous function never called'
|
10
|
+
True == False
|
11
|
+
}
|
12
|
+
|
13
|
+
test1 = (f, c, t) {
|
14
|
+
List(f, '->', c).Join == t
|
15
|
+
t.Strip(f).Strip('->') == c
|
16
|
+
t.Strip('->') == List(f, c).Join
|
17
|
+
}
|
18
|
+
|
19
|
+
test1.Type == 'Func'
|
20
|
+
|
21
|
+
Label = '$BlockLabel'
|
22
|
+
|
23
|
+
test1(*fruit, *color, *thing)
|
24
|
+
|
25
|
+
# XXX aocole suggests yanking the auto-sig feature.
|
26
|
+
test2 = {
|
27
|
+
thing ~~ color
|
28
|
+
}
|
29
|
+
|
30
|
+
test2(*color, *thing)
|
31
|
+
|
32
|
+
test3 = (a, b, c) {
|
33
|
+
f1(a) == b
|
34
|
+
f2(a) == c
|
35
|
+
}
|
36
|
+
|
37
|
+
test3(*input, *output1, *output2)
|
38
|
+
|
39
|
+
Label = 'Passing functions as objects'
|
40
|
+
|
41
|
+
test4 = (func, num) {
|
42
|
+
func.Type == 'Func'
|
43
|
+
func(num)
|
44
|
+
}
|
45
|
+
|
46
|
+
test5 = (num) {
|
47
|
+
num == 42
|
48
|
+
}
|
49
|
+
|
50
|
+
test4(test5, 42)
|
51
|
+
|
52
|
+
=== Red Apple
|
53
|
+
--- fruit: apple
|
54
|
+
--- color: red
|
55
|
+
--- thing: apple->red
|
56
|
+
|
57
|
+
=== Orange Orange
|
58
|
+
--- fruit: orange
|
59
|
+
--- color: orange
|
60
|
+
--- thing: orange->orange
|
61
|
+
|
62
|
+
=== Green Grape
|
63
|
+
--- fruit: grape
|
64
|
+
--- color: green
|
65
|
+
--- thing: grape->green
|
66
|
+
|
67
|
+
|
68
|
+
=== One
|
69
|
+
--- input: 1
|
70
|
+
--- output1: 43
|
71
|
+
--- output2: 2
|
72
|
+
|
73
|
+
=== Two
|
74
|
+
--- input: 2
|
75
|
+
--- output1: 86
|
76
|
+
--- output2: 6
|
77
|
+
|
78
|
+
=== Three
|
79
|
+
--- input: 5
|
80
|
+
--- output1: 215
|
81
|
+
--- output2: 30
|
82
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
%TestML 0.1.0
|
2
|
+
|
3
|
+
Plan = 4
|
4
|
+
|
5
|
+
Label = 'My label'
|
6
|
+
Get('Label') == 'My label'
|
7
|
+
|
8
|
+
Label = '$BlockLabel: $num) The $fruit'
|
9
|
+
GetLabel() == *text
|
10
|
+
|
11
|
+
=== A Fruity Test
|
12
|
+
--- num: 14
|
13
|
+
--- fruit: apple
|
14
|
+
--- text: A Fruity Test: 14) The apple
|
15
|
+
|
16
|
+
=== X
|
17
|
+
--- num: 21
|
18
|
+
--- fruit: pear
|
19
|
+
--- text: X: 21) The pear
|
20
|
+
|
21
|
+
=== Last Test
|
22
|
+
--- num: 99
|
23
|
+
--- fruit: tomato
|
24
|
+
--- text: Last Test: 99) The tomato
|
@@ -0,0 +1,50 @@
|
|
1
|
+
%TestML 0.1.0
|
2
|
+
|
3
|
+
Title = 'Test the TestML Standard Library'
|
4
|
+
Plan = 12
|
5
|
+
|
6
|
+
True.OK
|
7
|
+
False.Not.OK
|
8
|
+
None.Not.OK
|
9
|
+
*lines.Lines.Count == 12
|
10
|
+
*foo.Lines.Join(' - ') == *bar
|
11
|
+
*foo.Lines.Reverse.Text == *baz
|
12
|
+
*foo.Lines.Sort.Text == *baz.Lines.Sort.Text
|
13
|
+
*foo.Lines.Text == *foo
|
14
|
+
|
15
|
+
=== List
|
16
|
+
--- lines
|
17
|
+
sail
|
18
|
+
|
19
|
+
away
|
20
|
+
|
21
|
+
### Standard Calls
|
22
|
+
List
|
23
|
+
NOT
|
24
|
+
|
25
|
+
Lines/Text
|
26
|
+
Split(delim)/Join(delim)
|
27
|
+
Sort/NumSort/Reverse
|
28
|
+
Item(num)/Count
|
29
|
+
|
30
|
+
=== Test One
|
31
|
+
--- foo
|
32
|
+
a
|
33
|
+
b
|
34
|
+
c
|
35
|
+
--- bar: a - b - c
|
36
|
+
--- baz
|
37
|
+
c
|
38
|
+
b
|
39
|
+
a
|
40
|
+
|
41
|
+
=== Test Two
|
42
|
+
--- foo
|
43
|
+
I
|
44
|
+
like
|
45
|
+
pie!
|
46
|
+
--- bar: I - like - pie!
|
47
|
+
--- baz
|
48
|
+
pie!
|
49
|
+
like
|
50
|
+
I
|
@@ -0,0 +1,22 @@
|
|
1
|
+
%TestML 0.1.0
|
2
|
+
|
3
|
+
Plan = 9
|
4
|
+
|
5
|
+
Label = 'Boolean OK'
|
6
|
+
True.OK
|
7
|
+
False.Not.OK
|
8
|
+
True.Not.Not.OK
|
9
|
+
|
10
|
+
Label = 'String OK'
|
11
|
+
'Text'.OK
|
12
|
+
''.Not.OK
|
13
|
+
'0'.OK
|
14
|
+
|
15
|
+
Label = 'Number OK'
|
16
|
+
0.Not.OK
|
17
|
+
1.OK
|
18
|
+
42.OK
|
19
|
+
|
20
|
+
# XXX List context not yet supported.
|
21
|
+
# List("x\ny").OK
|
22
|
+
# List.Not.OK
|
@@ -0,0 +1,24 @@
|
|
1
|
+
%TestML 0.1.0
|
2
|
+
|
3
|
+
Plan = 11
|
4
|
+
|
5
|
+
Label = 'Test $TestNumber'
|
6
|
+
|
7
|
+
'Foo'.Type == 'Str'
|
8
|
+
42.Type == 'Num'
|
9
|
+
True.Type == 'Bool'
|
10
|
+
List(1,2,3).Type == 'List'
|
11
|
+
# [].Type == 'List'
|
12
|
+
{}.Type == 'Func'
|
13
|
+
(){}.Type == 'Func'
|
14
|
+
|
15
|
+
s = 'Foo'
|
16
|
+
s.Type == 'Str'
|
17
|
+
n = 42
|
18
|
+
n.Type == 'Num'
|
19
|
+
b = False
|
20
|
+
b.Type == 'Bool'
|
21
|
+
l = List()
|
22
|
+
l.Type == 'List'
|
23
|
+
f = {}
|
24
|
+
f.Type == 'Func'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require './lib/testml'
|
2
|
+
require './lib/testml/bridge'
|
3
|
+
require './lib/testml/util'
|
4
|
+
include TestML::Util
|
5
|
+
|
6
|
+
class TestMLBridge < TestML::Bridge
|
7
|
+
def uppercase string
|
8
|
+
str string.value.upcase
|
9
|
+
end
|
10
|
+
|
11
|
+
def lowercase string
|
12
|
+
str string.value.downcase
|
13
|
+
end
|
14
|
+
|
15
|
+
def combine *args
|
16
|
+
str args.flatten.map(&:value).join(' ')
|
17
|
+
end
|
18
|
+
|
19
|
+
def f1(num)
|
20
|
+
num = num.value.to_i
|
21
|
+
return str num * 42 + num
|
22
|
+
end
|
23
|
+
|
24
|
+
def f2(num)
|
25
|
+
num = num.value.to_i
|
26
|
+
return str num * num + num
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
12
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pegex
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.3
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.0.3
|
14
30
|
description: ! 'TestML is an Acmeist testing framework.
|
15
31
|
|
16
32
|
'
|
@@ -25,8 +41,57 @@ files:
|
|
25
41
|
- LICENSE
|
26
42
|
- README.rdoc
|
27
43
|
- Rakefile
|
44
|
+
- ToDo
|
45
|
+
- lib/rake/testml.rb
|
28
46
|
- lib/testml.rb
|
29
|
-
-
|
47
|
+
- lib/testml/bridge.rb
|
48
|
+
- lib/testml/compiler.rb
|
49
|
+
- lib/testml/compiler/lite.rb
|
50
|
+
- lib/testml/compiler/pegex.rb
|
51
|
+
- lib/testml/compiler/pegex/ast.rb
|
52
|
+
- lib/testml/compiler/pegex/grammar.rb
|
53
|
+
- lib/testml/library.rb
|
54
|
+
- lib/testml/library/debug.rb
|
55
|
+
- lib/testml/library/standard.rb
|
56
|
+
- lib/testml/runtime.rb
|
57
|
+
- lib/testml/runtime/unit.rb
|
58
|
+
- lib/testml/setup.rb
|
59
|
+
- lib/testml/util.rb
|
60
|
+
- test/ast/arguments.tml
|
61
|
+
- test/ast/basic.tml
|
62
|
+
- test/ast/dataless.tml
|
63
|
+
- test/ast/exceptions.tml
|
64
|
+
- test/ast/external.tml
|
65
|
+
- test/ast/function.tml
|
66
|
+
- test/ast/label.tml
|
67
|
+
- test/ast/markers.tml
|
68
|
+
- test/ast/semicolons.tml
|
69
|
+
- test/ast/truth.tml
|
70
|
+
- test/ast/types.tml
|
71
|
+
- test/compile-lite.rb
|
72
|
+
- test/compile-testml-document.rb
|
73
|
+
- test/compile.rb
|
74
|
+
- test/inline-bridge.rb
|
75
|
+
- test/inline.rb
|
76
|
+
- test/strings.rb
|
77
|
+
- test/testml.rb
|
78
|
+
- test/testml.yaml
|
79
|
+
- test/testml/arguments.tml
|
80
|
+
- test/testml/assertions.tml
|
81
|
+
- test/testml/basic.tml
|
82
|
+
- test/testml/dataless.tml
|
83
|
+
- test/testml/exceptions.tml
|
84
|
+
- test/testml/external.tml
|
85
|
+
- test/testml/external1.tml
|
86
|
+
- test/testml/external2.tml
|
87
|
+
- test/testml/function.tml
|
88
|
+
- test/testml/label.tml
|
89
|
+
- test/testml/markers.tml
|
90
|
+
- test/testml/semicolons.tml
|
91
|
+
- test/testml/standard.tml
|
92
|
+
- test/testml/truth.tml
|
93
|
+
- test/testml/types.tml
|
94
|
+
- test/testml_bridge.rb
|
30
95
|
homepage: http://testml.org
|
31
96
|
licenses:
|
32
97
|
- MIT
|