testml 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.gemspec +3 -1
  2. data/CHANGELOG.yaml +4 -1
  3. data/LICENSE +1 -1
  4. data/README.rdoc +30 -5
  5. data/Rakefile +10 -1
  6. data/ToDo +56 -0
  7. data/lib/rake/testml.rb +14 -0
  8. data/lib/testml.rb +46 -2
  9. data/lib/testml/bridge.rb +5 -0
  10. data/lib/testml/compiler.rb +106 -0
  11. data/lib/testml/compiler/lite.rb +194 -0
  12. data/lib/testml/compiler/pegex.rb +50 -0
  13. data/lib/testml/compiler/pegex/ast.rb +145 -0
  14. data/lib/testml/compiler/pegex/grammar.rb +173 -0
  15. data/lib/testml/library.rb +7 -0
  16. data/lib/testml/library/debug.rb +18 -0
  17. data/lib/testml/library/standard.rb +86 -0
  18. data/lib/testml/runtime.rb +501 -0
  19. data/lib/testml/runtime/unit.rb +94 -0
  20. data/lib/testml/setup.rb +65 -0
  21. data/lib/testml/util.rb +22 -0
  22. data/test/ast/arguments.tml +87 -0
  23. data/test/ast/basic.tml +83 -0
  24. data/test/ast/dataless.tml +36 -0
  25. data/test/ast/exceptions.tml +59 -0
  26. data/test/ast/external.tml +42 -0
  27. data/test/ast/function.tml +276 -0
  28. data/test/ast/label.tml +58 -0
  29. data/test/ast/markers.tml +36 -0
  30. data/test/ast/semicolons.tml +30 -0
  31. data/test/ast/truth.tml +85 -0
  32. data/test/ast/types.tml +163 -0
  33. data/test/compile-lite.rb +38 -0
  34. data/test/compile-testml-document.rb +59 -0
  35. data/test/compile.rb +57 -0
  36. data/test/inline-bridge.rb +30 -0
  37. data/test/inline.rb +28 -0
  38. data/test/strings.rb +24 -0
  39. data/test/testml.rb +38 -0
  40. data/test/testml.yaml +10 -0
  41. data/test/testml/arguments.tml +18 -0
  42. data/test/testml/assertions.tml +15 -0
  43. data/test/testml/basic.tml +37 -0
  44. data/test/testml/dataless.tml +9 -0
  45. data/test/testml/exceptions.tml +16 -0
  46. data/test/testml/external.tml +8 -0
  47. data/test/testml/external1.tml +10 -0
  48. data/test/testml/external2.tml +3 -0
  49. data/test/testml/function.tml +82 -0
  50. data/test/testml/label.tml +24 -0
  51. data/test/testml/markers.tml +19 -0
  52. data/test/testml/semicolons.tml +10 -0
  53. data/test/testml/standard.tml +50 -0
  54. data/test/testml/truth.tml +22 -0
  55. data/test/testml/types.tml +24 -0
  56. data/test/testml_bridge.rb +28 -0
  57. metadata +69 -4
  58. data/test/fail.rb +0 -12
data/test/testml.yaml ADDED
@@ -0,0 +1,10 @@
1
+ source_testml_dir: ../../testml-tml
2
+ local_testml_dir: ./testml
3
+ exclude_testml_files:
4
+ - comments.tml
5
+ - data.tml
6
+ - external1.tml
7
+ - external2.tml
8
+ - syntax.tml
9
+ - syntax2.tml
10
+ - topic.tml
@@ -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,9 @@
1
+ %TestML 0.1.0
2
+
3
+ Title = 'TestML with no data section'
4
+ Plan = 2
5
+ Label = 'Test $TestNumber'
6
+
7
+ 'foo' == "foo"
8
+
9
+ 'bar'.Str == "bar"
@@ -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,8 @@
1
+ %TestML 0.1.0
2
+
3
+ Plan = 4
4
+
5
+ *foo == *bar
6
+
7
+ %Include external2.tml
8
+ %Include external1.tml
@@ -0,0 +1,10 @@
1
+ === Test 1
2
+ --- foo: 98122
3
+ --- bar: 98122
4
+ === Test 11
5
+ --- foo: 90210
6
+ --- bar: 90210
7
+ === Test 111
8
+ --- foo: 60067
9
+ --- bar: 60067
10
+
@@ -0,0 +1,3 @@
1
+ === Test 2
2
+ --- foo: 02134
3
+ --- bar: 02134
@@ -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,19 @@
1
+ %TestML 0.1.0
2
+ %BlockMarker +++
3
+ %PointMarker ???
4
+
5
+ Plan = 2
6
+
7
+ *foo == *bar
8
+
9
+
10
+ +++ Test One
11
+ ??? foo: Hello
12
+ ??? bar: Hello
13
+
14
+
15
+ +++ Test Two
16
+ ??? foo
17
+ O HAI
18
+ ??? bar
19
+ O HAI
@@ -0,0 +1,10 @@
1
+ # Trailing semicolons are allowed, but we only allow one statement per line in
2
+ # TestML.
3
+
4
+ %TestML 0.1.0
5
+
6
+ Plan = 3;
7
+
8
+ 'one' == 'one'
9
+ 'two' == 'two';
10
+ 'three' == 'three'
@@ -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.1
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: 2012-12-20 00:00:00.000000000 Z
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
- - test/fail.rb
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