wabur 0.2.0d1 → 0.4.0d1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +40 -14
  3. data/bin/wabur +103 -0
  4. data/lib/wab/controller.rb +133 -90
  5. data/lib/wab/data.rb +14 -27
  6. data/lib/wab/errors.rb +14 -8
  7. data/lib/wab/impl/bool_expr.rb +25 -0
  8. data/lib/wab/impl/configuration.rb +166 -0
  9. data/lib/wab/impl/data.rb +155 -232
  10. data/lib/wab/impl/expr.rb +26 -0
  11. data/lib/wab/impl/expr_parser.rb +55 -0
  12. data/lib/wab/impl/exprs/and.rb +29 -0
  13. data/lib/wab/impl/exprs/between.rb +41 -0
  14. data/lib/wab/impl/exprs/eq.rb +28 -0
  15. data/lib/wab/impl/exprs/gt.rb +30 -0
  16. data/lib/wab/impl/exprs/gte.rb +30 -0
  17. data/lib/wab/impl/exprs/has.rb +26 -0
  18. data/lib/wab/impl/exprs/in.rb +28 -0
  19. data/lib/wab/impl/exprs/lt.rb +30 -0
  20. data/lib/wab/impl/exprs/lte.rb +30 -0
  21. data/lib/wab/impl/exprs/not.rb +27 -0
  22. data/lib/wab/impl/exprs/or.rb +29 -0
  23. data/lib/wab/impl/exprs/regex.rb +28 -0
  24. data/lib/wab/impl/handler.rb +95 -0
  25. data/lib/wab/impl/model.rb +197 -0
  26. data/lib/wab/impl/path_expr.rb +14 -0
  27. data/lib/wab/impl/shell.rb +92 -7
  28. data/lib/wab/impl/utils.rb +110 -0
  29. data/lib/wab/impl.rb +24 -0
  30. data/lib/wab/io/call.rb +4 -7
  31. data/lib/wab/io/engine.rb +128 -51
  32. data/lib/wab/io/shell.rb +61 -64
  33. data/lib/wab/io.rb +0 -2
  34. data/lib/wab/open_controller.rb +43 -0
  35. data/lib/wab/shell.rb +46 -61
  36. data/lib/wab/shell_logger.rb +13 -0
  37. data/lib/wab/utils.rb +36 -0
  38. data/lib/wab/uuid.rb +3 -6
  39. data/lib/wab/version.rb +2 -2
  40. data/lib/wab.rb +3 -0
  41. data/pages/Plan.md +20 -14
  42. data/test/bench_io_shell.rb +49 -0
  43. data/test/{impl_test.rb → helper.rb} +2 -4
  44. data/test/mirror_controller.rb +16 -0
  45. data/test/test_configuration.rb +38 -0
  46. data/test/test_data.rb +207 -0
  47. data/test/test_expr.rb +35 -0
  48. data/test/test_expr_and.rb +24 -0
  49. data/test/test_expr_between.rb +43 -0
  50. data/test/test_expr_eq.rb +24 -0
  51. data/test/test_expr_gt.rb +24 -0
  52. data/test/test_expr_gte.rb +24 -0
  53. data/test/test_expr_has.rb +19 -0
  54. data/test/test_expr_in.rb +24 -0
  55. data/test/test_expr_lt.rb +24 -0
  56. data/test/test_expr_lte.rb +24 -0
  57. data/test/test_expr_not.rb +22 -0
  58. data/test/test_expr_or.rb +24 -0
  59. data/test/test_expr_regex.rb +30 -0
  60. data/test/test_impl.rb +38 -0
  61. data/test/test_io_shell.rb +189 -0
  62. data/test/test_model.rb +31 -0
  63. data/test/test_runner.rb +177 -0
  64. data/test/tests.rb +3 -8
  65. metadata +91 -18
  66. data/lib/wab/model.rb +0 -136
  67. data/lib/wab/view.rb +0 -21
  68. data/test/data_test.rb +0 -253
  69. data/test/ioshell_test.rb +0 -461
data/lib/wab/uuid.rb CHANGED
@@ -6,19 +6,16 @@ module WAB
6
6
  class UUID
7
7
 
8
8
  attr_reader :id
9
-
9
+
10
10
  # Initializes a UUID from string representation of the UUID
11
11
  # following the pattern "123e4567-e89b-12d3-a456-426655440000".
12
12
  def initialize(id)
13
13
  @id = id.downcase
14
- # TBD change to WAB exception
15
- raise Exception.new("Invalid UUID format.") if /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.match(@id).nil?
14
+ raise WAB::ParseError.new('Invalid UUID format.') unless WAB::Utils.uuid_format?(@id)
16
15
  end
17
16
 
18
17
  # Returns the string representation of the UUID.
19
- def to_s
20
- @id
21
- end
18
+ alias to_s id
22
19
 
23
20
  def ==(other)
24
21
  other.is_a?(self.class) && @id == other.id
data/lib/wab/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module WAB
3
- # Current version of the module.
4
- VERSION = '0.2.0d1'
3
+ # Current version of the module.
4
+ VERSION = '0.4.0d1'
5
5
  end
data/lib/wab.rb CHANGED
@@ -6,6 +6,9 @@ end
6
6
  require 'wab/controller'
7
7
  require 'wab/data'
8
8
  require 'wab/errors'
9
+ require 'wab/open_controller'
9
10
  require 'wab/shell'
11
+ require 'wab/shell_logger'
12
+ require 'wab/utils'
10
13
  require 'wab/uuid'
11
14
  require 'wab/version'
data/pages/Plan.md CHANGED
@@ -2,20 +2,26 @@
2
2
 
3
3
  More details will be added here as progress continues. For now the high level plan is:
4
4
 
5
- - _Define APIs - initial complete_
5
+ ### Completed
6
6
 
7
- - Start the WAB::Dev module
8
- - WAB::Dev::Data class
9
- - WAB::Dev::UUID class
10
- - WAB::Dev::Model class
11
- - WAB::Dev::Shell class
12
- - WAB::Dev::View class
13
- - WAB::Dev::Controller class
7
+ - _Define APIs - initial complete_
8
+ - _WAB::IO::Shell - complete_
9
+ - _stdio sample - complete_
14
10
 
15
- - Extern Glue implemenation and test
16
- - this is in the WAB module
11
+ ### Pending
17
12
 
18
- - Structure Ruby Framework
19
- - Embedded Glue layer
20
- - External Glue layer
21
-
13
+ - Benchmarks - started
14
+ - Overall as a black box
15
+ - WAB::IO::Shell alone
16
+ - Spec driven Javascript libraries
17
+ - Define spec format
18
+ - implement and test generic Javascript app
19
+ - Ruby Runner
20
+ - Runner framework
21
+ - HTTP server
22
+ - Model
23
+ - In memory object management
24
+ - Data store
25
+ - Embedded Ruby Runner (separate project)
26
+ - End to end examples
27
+ - Advanced Javascript displays
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ require 'benchmark'
7
+
8
+ require 'wab/impl'
9
+ require 'wab/io'
10
+ require 'mirror_controller'
11
+
12
+ # Windows does not support fork
13
+ Process.exit(-1) if RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
14
+
15
+ to_r, to_w = IO.pipe
16
+ from_r, from_w = IO.pipe
17
+
18
+ if fork.nil? # child
19
+ $stdin = to_r
20
+ to_w.close
21
+ $stdout = from_w
22
+ from_r.close
23
+
24
+ shell = WAB::IO::Shell.new(1, 'kind', 0)
25
+ shell.timeout = 0.5
26
+ shell.logger.level = Logger::WARN # change to Logger::INFO for debugging
27
+ shell.register_controller(nil, MirrorController.new(shell))
28
+ shell.start
29
+
30
+ Process.exit(0)
31
+ else
32
+ to_r.close
33
+ from_w.close
34
+
35
+ # Using simple timing to make it easier to report results.
36
+ n = 10000
37
+ reply = nil
38
+ start = Time.now
39
+ n.times { |i|
40
+ to_w.puts(WAB::Impl::Data.new({rid: 'rid-read-id', api: 1, body: {op: 'GET', path: ['sample', '12345']}}, false).json)
41
+ to_w.flush
42
+ Oj.strict_load(from_r, symbol_keys: true) { |msg| reply = msg; break }
43
+ to_w.puts(WAB::Impl::Data.new({rid: "#{i+1}", api: 4, body: {code: 0, results:[{kind: 'sample', id: 12345, num: 7}]}}, false).json)
44
+ to_w.flush
45
+ Oj.strict_load(from_r, symbol_keys: true) { |msg| reply = msg; break }
46
+ }
47
+ dt = Time.now - start
48
+ puts "#{n} simulated GETs in #{dt} seconds. #{(dt * 1000000.0 /n).to_i} usecs/GET or #{(n / dt).to_i} GETs/sec"
49
+ end
@@ -1,11 +1,9 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
2
 
4
- $: << __dir__
3
+ $LOAD_PATH << __dir__
4
+ $LOAD_PATH << File.expand_path('../lib', __dir__)
5
5
 
6
6
  require 'minitest'
7
7
  require 'minitest/autorun'
8
8
 
9
9
  require 'wab/impl'
10
-
11
- require 'data_test'
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require 'wab'
5
+ require 'wab/impl'
6
+
7
+ class MirrorController < WAB::OpenController
8
+ def initialize(shell)
9
+ super(shell)
10
+ end
11
+
12
+ def handle(data)
13
+ data
14
+ end
15
+
16
+ end # MirrorController
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ class TestConfiguration < TestImpl
4
+ def setup
5
+ usage_string = 'Test Banner'
6
+ options_map = {
7
+ environment: {
8
+ val: 'test',
9
+ type: String,
10
+ doc: 'Configure the environment for this session',
11
+ short: '-e',
12
+ arg: 'ENV',
13
+ }
14
+ }
15
+ @config = WAB::Impl::Configuration.new(usage_string, options_map)
16
+ end
17
+
18
+ def test_initialization
19
+ assert_equal({:environment=>"test"}, @config.map )
20
+ end
21
+
22
+ def test_parse_config_file
23
+ expected = {
24
+ :store => { :dir => "$BASE/test/store/data" },
25
+ :handler => [{ :type =>"Article" }],
26
+ :http => { :dir => "$BASE/view/test-pages" }
27
+ }
28
+ assert_equal(expected,
29
+ @config.parse_config_file(File.expand_path('samples/test-config.conf', __dir__))
30
+ )
31
+ assert_equal(expected,
32
+ @config.parse_config_file(File.expand_path('samples/test-config.json', __dir__))
33
+ )
34
+ assert_raises(LoadError) {
35
+ @config.parse_config_file(File.expand_path('samples/test-config.yml', __dir__))
36
+ }
37
+ end
38
+ end # TestConfiguration
data/test/test_data.rb ADDED
@@ -0,0 +1,207 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ require 'wab'
7
+ require 'wab/impl'
8
+
9
+ class TestImplData < TestImpl
10
+
11
+ class ToHash
12
+ def initialize(x, y)
13
+ @h = {x: x, y: y }
14
+ end
15
+
16
+ def to_h
17
+ @h
18
+ end
19
+ end
20
+
21
+ def test_json
22
+ d = make_sample_data
23
+ # downcase to match Ruby 2.3 and 2.4 which encode BigDecimal differently.
24
+ assert_equal(%|{
25
+ "boo":true,
26
+ "n":null,
27
+ "num":7,
28
+ "float":7.654,
29
+ "str":"a string",
30
+ "t":"2017-01-05t15:04:33.123456789z",
31
+ "big":0.6321e2,
32
+ "uri":"http://opo.technology/sample",
33
+ "uuid":"b0ca922d-372e-41f4-8fea-47d880188ba3",
34
+ "a":[],
35
+ "h":{}
36
+ }
37
+ |, d.json(2).downcase)
38
+ end
39
+
40
+ def test_validate_keys
41
+ assert_raises(WAB::KeyError) { d = @shell.data({ 'a' => 1}) }
42
+ assert_raises(WAB::TypeError) { d = @shell.data('text') }
43
+ end
44
+
45
+ def test_repair_keys
46
+ d = @shell.data({ 'a' => 1}, true)
47
+ assert_equal({a:1}, d.native, 'data not repaired')
48
+ end
49
+
50
+ def test_validate_non_hash_array
51
+ assert_raises { d = @shell.data(123) }
52
+ end
53
+
54
+ def test_fix_non_hash_array
55
+ # can not fix this one
56
+ assert_raises { d = @shell.data(123, true) }
57
+ end
58
+
59
+ def test_validate_object
60
+ assert_raises { d = @shell.data({a: 1..3}) }
61
+ end
62
+
63
+ def test_repair_to_s_object
64
+ d = @shell.data({a: 1..3}, true)
65
+ assert_equal({a:'1..3'}, d.native, 'data not repaired')
66
+ end
67
+
68
+ def test_repair_to_h_object
69
+ d = @shell.data(ToHash.new(1, 2), true)
70
+ assert_equal({x:1,y:2}, d.native, 'data not repaired')
71
+ end
72
+
73
+ def test_hash_get
74
+ d = @shell.data({a: 1, b: 2})
75
+ assert_equal(2, d.get('b'), "failed to get 'b'")
76
+ assert_equal(2, d.get([:b]), 'failed to get [:b]')
77
+ assert_equal(1, d.get(['a']), "failed to get ['a']")
78
+ assert_nil(d.get(['d']), "failed to get ['d']")
79
+ end
80
+
81
+ def test_array_get
82
+ d = @shell.data(['a', 'b', 'c'])
83
+ assert_equal('b', d.get('1'), "failed to get '1'")
84
+ assert_equal('c', d.get(['2']), "failed to get ['2']")
85
+ assert_equal('b', d.get([1]), 'failed to get [1]')
86
+ assert_equal('a', d.get([0]), 'failed to get [0]')
87
+ assert_equal('c', d.get([-1]), 'failed to get [-1]')
88
+ assert_nil(d.get([4]), 'failed to get [4]')
89
+ end
90
+
91
+ def test_get_mixed
92
+ d = @shell.data({a: 1, b: ['a', 'b', { c: 3}]})
93
+ assert_equal(3, d.get('b.2.c'), "failed to get 'b.2.c'")
94
+ assert_equal(3, d.get([:b, 2, 'c']), 'failed to get [b, 2, c]')
95
+ end
96
+
97
+ def test_hash_set
98
+ d = @shell.data({a: 1})
99
+ d.set('b', 2)
100
+ d.set([:c], 3)
101
+ d.set([:d], 1..4, true)
102
+ assert_raises { d.set([:e], 1..5) }
103
+ assert_equal(%|{
104
+ "a":1,
105
+ "b":2,
106
+ "c":3,
107
+ "d":"1..4"
108
+ }
109
+ |, d.json(2))
110
+ # replace existing
111
+ d.set([:c], -3)
112
+ assert_equal(%|{
113
+ "a":1,
114
+ "b":2,
115
+ "c":-3,
116
+ "d":"1..4"
117
+ }
118
+ |, d.json(2))
119
+ end
120
+
121
+ def test_array_set
122
+ d = @shell.data(['x'])
123
+ d.set([2], 'd')
124
+ assert_equal(%|["x",null,"d"]|, d.json, 'after d')
125
+ d.set([1], 'c')
126
+ assert_equal(%|["x","c","d"]|, d.json, 'after c')
127
+ d.set([0], 'y')
128
+ assert_equal(%|["y","c","d"]|, d.json, 'after y')
129
+ d.set([-3], 'b')
130
+ assert_equal(%|["b","c","d"]|, d.json, 'after b')
131
+ d.set([-4], 'a')
132
+ assert_equal(%|["a","b","c","d"]|, d.json, 'after a')
133
+ end
134
+
135
+ def test_set_mixed
136
+ d = @shell.data({a: 1, b: ['a', 'b', { c: 3}]})
137
+ d.set('b.2', 'c')
138
+ assert_equal(%|{"a":1,"b":["a","b","c"]}|, d.json)
139
+ end
140
+
141
+ def test_each
142
+ d = @shell.data({a: 1, b: ['a', 'b', { c: 3}]})
143
+ paths = []
144
+ values = []
145
+ d.each { |p, v|
146
+ paths << p
147
+ values << v
148
+ }
149
+ assert_equal([[], [:a], [:b], [:b, 0], [:b, 1], [:b, 2], [:b, 2, :c]], paths, 'paths mismatch')
150
+ assert_equal([{:a=>1, :b=>['a', 'b', {:c=>3}]}, 1, ['a', 'b', {:c=>3}], 'a', 'b', {:c=>3}, 3], values, 'values mismatch')
151
+ end
152
+
153
+ def test_each_leaf
154
+ d = @shell.data({a: 1, b: ['a', 'b', { c: 3}]})
155
+ paths = []
156
+ values = []
157
+ d.each_leaf { |p, v|
158
+ paths << p
159
+ values << v
160
+ }
161
+ assert_equal([[:a], [:b, 0], [:b, 1], [:b, 2, :c]], paths, 'paths mismatch')
162
+ assert_equal([1, 'a', 'b', 3], values, 'values mismatch')
163
+ end
164
+
165
+ def test_eql
166
+ d = @shell.data({a: 1, b: ['a', 'b', { c: 3}]})
167
+ d2 = @shell.data({a: 1, b: ['a', 'b', { c: 3}]})
168
+ d3 = @shell.data({a: 1, b: ['a', 'b', { d: 3}]})
169
+ d4 = @shell.data({a: 1, b: ['a', 'b', { c: 4}]})
170
+
171
+ assert(d.native == d2.native, 'same keys and values should be eql')
172
+ assert(!(d.native == d3.native), 'same values different keys should not be eql')
173
+ assert(!(d.native == d4.native), 'same keys different values should not be eql')
174
+ end
175
+
176
+ def test_deep_dup
177
+ d = @shell.data({a: 1, b: ['a', 'b', { c: 3}]})
178
+ c = d.deep_dup
179
+ assert(d.native == c.native)
180
+ end
181
+
182
+ def test_detect
183
+ d = @shell.data({
184
+ t: '2017-01-05T15:04:33.123456789Z',
185
+ uris: ['http://opo.technology/sample'],
186
+ sub:{
187
+ uuid: 'b0ca922d-372e-41f4-8fea-47d880188ba3'
188
+ }
189
+ })
190
+ d.detect
191
+ assert_equal(%|{
192
+ "t":"2017-01-05t15:04:33.123456789z",
193
+ "uris":[
194
+ "http://opo.technology/sample"
195
+ ],
196
+ "sub":{
197
+ "uuid":"b0ca922d-372e-41f4-8fea-47d880188ba3"
198
+ }
199
+ }
200
+ |, d.json(2).downcase)
201
+
202
+ assert_equal(Time, d.get('t').class)
203
+ assert_equal(::URI::HTTP, d.get('uris.0').class)
204
+ assert_equal(WAB::UUID, d.get('sub.uuid').class)
205
+ end
206
+
207
+ end # TestImplData
data/test/test_expr.rb ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ require 'wab/impl/expr_parser'
7
+
8
+ require 'test_expr_between'
9
+ require 'test_expr_eq'
10
+ require 'test_expr_gt'
11
+ require 'test_expr_gte'
12
+ require 'test_expr_has'
13
+ require 'test_expr_in'
14
+ require 'test_expr_lt'
15
+ require 'test_expr_lte'
16
+ require 'test_expr_regex'
17
+
18
+ require 'test_expr_not'
19
+ require 'test_expr_and'
20
+ require 'test_expr_or'
21
+
22
+ class TestExpr < TestImpl
23
+
24
+ def test_expr_parser_parse
25
+ natives = [
26
+ ['EQ', 'num', 7],
27
+ ['AND', ['HAS', 'str'], ['EQ', 'num', 7]],
28
+ ]
29
+ natives.each { |n|
30
+ x = WAB::Impl::ExprParser.parse(n)
31
+ assert_equal(n, x.native, "parsed failed for #{n}")
32
+ }
33
+ end
34
+
35
+ end # TestExpr
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ class TestExprAnd < TestImpl
7
+
8
+ def test_and_native
9
+ x = WAB::Impl::And.new(WAB::Impl::Has.new('num'), WAB::Impl::Eq.new('num', 7))
10
+ assert_equal(['AND', ['HAS', 'num'], ['EQ', 'num', 7]], x.native, 'AND native mismatch')
11
+ end
12
+
13
+ def test_and
14
+ d = make_sample_data
15
+ x = WAB::Impl::And.new(WAB::Impl::Has.new('num'), WAB::Impl::Eq.new('num', 7))
16
+ assert(x.eval(d), 'checking AND match')
17
+
18
+ x = WAB::Impl::And.new(WAB::Impl::Has.new('num'), WAB::Impl::Eq.new('num', 8))
19
+ refute(x.eval(d), 'checking AND mismatch')
20
+ end
21
+
22
+ # TBD tests with no args, with one, with more than 2, test using append_arg
23
+
24
+ end # TestExprAnd
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ class TestExprBetween < TestImpl
7
+
8
+ def test_between_native
9
+ x = WAB::Impl::Between.new('num', 3, 7, true, false)
10
+ assert_equal(['BETWEEN', 'num', 3, 7, true, false], x.native, 'BETWEEN native mismatch')
11
+ end
12
+
13
+ def test_between_int
14
+ d = make_sample_data
15
+ x = WAB::Impl::Between.new('num', 7, 10)
16
+ assert(x.eval(d), 'checking BETWEEN match with an integer arg')
17
+
18
+ x = WAB::Impl::Between.new('num', 8, 10)
19
+ refute(x.eval(d), 'checking BETWEEN mismatch with an integer arg')
20
+
21
+ x = WAB::Impl::Between.new('num', 5, 7)
22
+ assert(x.eval(d), 'checking BETWEEN match with an integer arg')
23
+
24
+ x = WAB::Impl::Between.new('num', 5, 6)
25
+ refute(x.eval(d), 'checking BETWEEN mismatch with an integer arg')
26
+
27
+ # exclusive of min
28
+ x = WAB::Impl::Between.new('num', 6, 10, false)
29
+ assert(x.eval(d), 'checking BETWEEN match with an integer arg')
30
+
31
+ x = WAB::Impl::Between.new('num', 7, 10, false)
32
+ refute(x.eval(d), 'checking BETWEEN mismatch with an integer arg')
33
+
34
+ x = WAB::Impl::Between.new('num', 5, 8, false, false)
35
+ assert(x.eval(d), 'checking BETWEEN match with an integer arg')
36
+
37
+ x = WAB::Impl::Between.new('num', 5, 7, false, false)
38
+ refute(x.eval(d), 'checking BETWEEN mismatch with an integer arg')
39
+ end
40
+
41
+ # TBD more tests for each type, Float, boolean, String, URI, UUID, Time, BigDecimal, nil
42
+
43
+ end # TestExprBetween
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ class TestExprEq < TestImpl
7
+
8
+ def test_eq_native
9
+ x = WAB::Impl::Eq.new('num', 7)
10
+ assert_equal(['EQ', 'num', 7], x.native, 'EQ native mismatch')
11
+ end
12
+
13
+ def test_eq_int
14
+ d = make_sample_data
15
+ x = WAB::Impl::Eq.new('num', 7)
16
+ assert(x.eval(d), 'checking EQ match with an integer arg')
17
+
18
+ x = WAB::Impl::Eq.new('num', 17)
19
+ refute(x.eval(d), 'checking EQ mismatch with an integer arg')
20
+ end
21
+
22
+ # TBD more tests for each type, Float, boolean, String, URI, UUID, Time, BigDecimal, nil
23
+
24
+ end # TestExprEq
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ class TestExprGt < TestImpl
7
+
8
+ def test_gt_native
9
+ x = WAB::Impl::Gt.new('num', 3)
10
+ assert_equal(['GT', 'num', 3], x.native, 'GT native mismatch')
11
+ end
12
+
13
+ def test_gt_int
14
+ d = make_sample_data
15
+ x = WAB::Impl::Gt.new('num', 6)
16
+ assert(x.eval(d), 'checking GT match with an integer arg')
17
+
18
+ x = WAB::Impl::Gt.new('num', 7)
19
+ refute(x.eval(d), 'checking GT mismatch with an integer arg')
20
+ end
21
+
22
+ # TBD more tests for each type, Float, boolean, String, URI, UUID, Time, BigDecimal, nil
23
+
24
+ end # TestExprGt
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ class TestExprGte < TestImpl
7
+
8
+ def test_gte_native
9
+ x = WAB::Impl::Gte.new('num', 3)
10
+ assert_equal(['GTE', 'num', 3], x.native, 'GTE native mismatch')
11
+ end
12
+
13
+ def test_gte_int
14
+ d = make_sample_data
15
+ x = WAB::Impl::Gte.new('num', 7)
16
+ assert(x.eval(d), 'checking GTE match with an integer arg')
17
+
18
+ x = WAB::Impl::Gte.new('num', 8)
19
+ refute(x.eval(d), 'checking GTE mismatch with an integer arg')
20
+ end
21
+
22
+ # TBD more tests for each type, Float, boolean, String, URI, UUID, Time, BigDecimal, nil
23
+
24
+ end # TestExprGte
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ class TestExprHas < TestImpl
7
+
8
+ def test_has_int
9
+ d = make_sample_data
10
+ x = WAB::Impl::Has.new('num')
11
+ assert(x.eval(d), 'checking HAS match')
12
+
13
+ x = WAB::Impl::Has.new('none')
14
+ refute(x.eval(d), 'checking HAS mismatch')
15
+ end
16
+
17
+ # TBD test with path as an array, tests with symbol path
18
+
19
+ end # TestExprHas
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ class TestExprIn < TestImpl
7
+
8
+ def test_in_native
9
+ x = WAB::Impl::In.new('num', 3, 4, 5)
10
+ assert_equal(['IN', 'num', 3, 4, 5], x.native, 'IN native mismatch')
11
+ end
12
+
13
+ def test_in_int
14
+ d = make_sample_data
15
+ x = WAB::Impl::In.new('num', 1, 3, 5, 7, 11)
16
+ assert(x.eval(d), 'checking IN match with an integer arg')
17
+
18
+ x = WAB::Impl::In.new('num', 0, 2, 4, 6, 8, 10)
19
+ refute(x.eval(d), 'checking IN mismatch with an integer arg')
20
+ end
21
+
22
+ # TBD more tests for each type, Float, boolean, String, URI, UUID, Time, BigDecimal, nil
23
+
24
+ end # TestExprIn
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ class TestExprLt < TestImpl
7
+
8
+ def test_lt_native
9
+ x = WAB::Impl::Lt.new('num', 3)
10
+ assert_equal(['LT', 'num', 3], x.native, 'LT native mismatch')
11
+ end
12
+
13
+ def test_lt_int
14
+ d = make_sample_data
15
+ x = WAB::Impl::Lt.new('num', 8)
16
+ assert(x.eval(d), 'checking LT match with an integer arg')
17
+
18
+ x = WAB::Impl::Lt.new('num', 7)
19
+ refute(x.eval(d), 'checking LT mismatch with an integer arg')
20
+ end
21
+
22
+ # TBD more tests for each type, Float, boolean, String, URI, UUID, Time, BigDecimal, nil
23
+
24
+ end # TestExprLt
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ require_relative 'helper'
5
+
6
+ class TestExprLte < TestImpl
7
+
8
+ def test_lte_native
9
+ x = WAB::Impl::Lte.new('num', 3)
10
+ assert_equal(['LTE', 'num', 3], x.native, 'LTE native mismatch')
11
+ end
12
+
13
+ def test_lte_int
14
+ d = make_sample_data
15
+ x = WAB::Impl::Lte.new('num', 7)
16
+ assert(x.eval(d), 'checking LTE match with an integer arg')
17
+
18
+ x = WAB::Impl::Lte.new('num', 6)
19
+ refute(x.eval(d), 'checking LTE mismatch with an integer arg')
20
+ end
21
+
22
+ # TBD more tests for each type, Float, boolean, String, URI, UUID, Time, BigDecimal, nil
23
+
24
+ end # TestExprLte