-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpredicator_test.exs
533 lines (438 loc) · 22.2 KB
/
predicator_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
defmodule PredicatorTest do
use ExUnit.Case
import Predicator
doctest Predicator
@moduletag :parsing
describe "BOOLEAN" do
test "commpiles string key instructions" do
assert {:ok, [["load", "foo"], ["to_bool"]]} = Predicator.compile("foo")
assert {:ok, [["load", "foo"], ["to_bool"], ["not"]]} = Predicator.compile("!foo")
assert {:ok, [["lit", true]]} = Predicator.compile("true")
assert {:ok, [["lit", false]]} = Predicator.compile("false")
end
test "compiles atom key instructions" do
assert {:ok, [[:load, :foo], [:to_bool]]} = Predicator.compile("foo", :atom_key_inst)
assert {:ok, [[:load, :foo], [:to_bool], [:not]]} =
Predicator.compile("!foo", :atom_key_inst)
assert {:ok, [[:lit, true]]} = Predicator.compile("true", :atom_key_inst)
assert {:ok, [[:lit, false]]} = Predicator.compile("false", :atom_key_inst)
assert {:ok, [[:lit, true], [:not]]} = Predicator.compile("!true", :atom_key_inst)
assert {:ok, [[:lit, false], [:not]]} = Predicator.compile("!false", :atom_key_inst)
end
test "evaluates to true" do
assert Predicator.matches?("true") == true
assert Predicator.matches?("!false") == true
assert Predicator.matches?("foo", foo: true) == true
assert Predicator.matches?("!foo", foo: false) == true
end
test "evaluates to false" do
assert Predicator.matches?("!true") == false
assert Predicator.matches?("false") == false
assert Predicator.matches?("foo", foo: false) == false
assert Predicator.matches?("!foo", foo: true) == false
end
end
describe "BETWEEN" do
test "compiles atom key instructions" do
assert {:ok, [[:load, :age], [:lit, 5], [:lit, 10], [:compare, :BETWEEN]]} =
Predicator.compile("age between 5 and 10", :atom_key_inst)
assert {:ok, [[:load, :age], [:lit, 5], [:lit, 10], [:compare, :BETWEEN], [:not]]} =
Predicator.compile("!age between 5 and 10", :atom_key_inst)
end
test "compiles string key instructions" do
assert {:ok, [["load", "age"], ["lit", 5], ["lit", 10], ["compare", "BETWEEN"], ["not"]]} =
Predicator.compile("!age between 5 and 10")
end
test "evaluates to true" do
assert Predicator.matches?("7 between 5 and 10") == true
assert Predicator.matches?("!32 between 5 and 10") == true
assert Predicator.matches?("age between 5 and 10", age: 7) == true
assert Predicator.matches?("!age between 5 and 10", age: 14) == true
end
test "evaluates to false" do
assert Predicator.matches?("32 between 5 and 10") == false
assert Predicator.matches?("!7 between 5 and 10") == false
assert Predicator.matches?("age between 5 and 10", age: 14) == false
assert Predicator.matches?("!age between 5 and 10", age: 7) == false
assert Predicator.matches?("age between 5 and 10", age: nil) == false
end
end
describe "STARTSWITH" do
test "compiles atom key instructions" do
assert {:ok, [[:load, :name], [:lit, "stuff"], [:compare, :STARTSWITH]]} =
Predicator.compile("name starts with 'stuff'", :atom_key_inst)
assert {:ok, [[:load, :name], [:lit, "stuff"], [:compare, :STARTSWITH], [:not]]} =
Predicator.compile("!name starts with 'stuff'", :atom_key_inst)
assert {:ok, [[:lit, "name"], [:lit, "stuff"], [:compare, :STARTSWITH]]} =
Predicator.compile("'name' starts with 'stuff'", :atom_key_inst)
assert {:ok, [[:lit, "name"], [:lit, "stuff"], [:compare, :STARTSWITH], [:not]]} =
Predicator.compile("!'name' starts with 'stuff'", :atom_key_inst)
end
test "compiles string key instructions" do
assert {:ok, [["load", "name"], ["lit", "stuff"], ["compare", "STARTSWITH"]]} =
Predicator.compile("name starts with 'stuff'")
assert {:ok, [["load", "name"], ["lit", "stuff"], ["compare", "STARTSWITH"], ["not"]]} =
Predicator.compile("!name starts with 'stuff'")
assert {:ok, [["lit", "name"], ["lit", "stuff"], ["compare", "STARTSWITH"]]} =
Predicator.compile("'name' starts with 'stuff'")
assert {:ok, [["lit", "name"], ["lit", "stuff"], ["compare", "STARTSWITH"], ["not"]]} =
Predicator.compile("!'name' starts with 'stuff'")
assert {:ok, [["lit", "name"], ["lit", "stuff"], ["compare", "STARTSWITH"]]} =
Predicator.compile("\"name\" starts with \"stuff\"")
end
test "returns true" do
assert Predicator.matches?("'joaquin' starts with 'joa'") == true
assert Predicator.matches?("!'name' starts with 'stuff'") == true
assert Predicator.matches?("name starts with 'joa'", name: "joaquin") == true
assert Predicator.matches?("!name starts with 'stuff'", name: "joaquin") == true
end
test "returns false" do
assert Predicator.matches?("'name' starts with 'stuff'") == false
assert Predicator.matches?("!'joaquin' starts with 'joa'") == false
assert Predicator.matches?("name starts with 'stuff'", name: "joaquin") == false
assert Predicator.matches?("!name starts with 'joa'", name: "joaquin") == false
assert Predicator.matches?("name starts with 'joa'", name: nil) == false
end
end
describe "ENDSWITH" do
test "compiles atom key instructions" do
assert {:ok, [[:load, :foobar], [:lit, "bar"], [:compare, :ENDSWITH]]} =
Predicator.compile("foobar ends with 'bar'", :atom_key_inst)
assert {:ok, [[:load, :foobar], [:lit, "bar"], [:compare, :ENDSWITH], [:not]]} =
Predicator.compile("!foobar ends with 'bar'", :atom_key_inst)
assert {:ok, [[:lit, "foobar"], [:lit, "bar"], [:compare, :ENDSWITH]]} =
Predicator.compile("'foobar' ends with 'bar'", :atom_key_inst)
assert {:ok, [[:lit, "foobar"], [:lit, "bar"], [:compare, :ENDSWITH], [:not]]} =
Predicator.compile("!'foobar' ends with 'bar'", :atom_key_inst)
end
test "compiles string key instructions" do
assert {:ok, [["lit", "foobar"], ["lit", "bar"], ["compare", "ENDSWITH"]]} =
Predicator.compile("'foobar' ends with 'bar'")
assert {:ok, [["lit", "foobar"], ["lit", "bar"], ["compare", "ENDSWITH"], ["not"]]} =
Predicator.compile("!'foobar' ends with 'bar'")
assert {:ok, [["load", "foobar"], ["lit", "bar"], ["compare", "ENDSWITH"]]} =
Predicator.compile("foobar ends with 'bar'")
assert {:ok, [["load", "foobar"], ["lit", "bar"], ["compare", "ENDSWITH"], ["not"]]} =
Predicator.compile("!foobar ends with 'bar'")
end
test "evaluates to true" do
assert Predicator.matches?("'foobar' ends with 'bar'") == true
assert Predicator.matches?("!'world' ends with 'bar'") == true
assert Predicator.matches?("foobar ends with 'bar'", foobar: "foobar") == true
assert Predicator.matches?("!foobar ends with 'bar'", foobar: "world") == true
end
test "evaluates to false" do
assert Predicator.matches?("'world' ends with 'bar'") == false
assert Predicator.matches?("!'foobar' ends with 'bar'") == false
assert Predicator.matches?("foobar ends with 'bar'", foobar: "world") == false
assert Predicator.matches?("!foobar ends with 'bar'", foobar: "foobar") == false
assert Predicator.matches?("foobar ends with 'bar'", foobar: nil) == false
end
end
describe "EQ" do
test "compiles atom key instructions" do
assert {:ok, [[:load, :foo], [:lit, 1], [:compare, :EQ]]} =
Predicator.compile("foo = 1", :atom_key_inst)
assert {:ok, [[:load, :foo], [:lit, "bar"], [:compare, :EQ], [:not]]} =
Predicator.compile("!foo = \"bar\"", :atom_key_inst)
end
test "compiles string key instructions" do
assert {:ok, [["load", "foo"], ["lit", 1], ["compare", "EQ"]]} =
Predicator.compile("foo = 1")
assert {:ok, [["load", "foo"], ["lit", "bar"], ["compare", "EQ"], ["not"]]} =
Predicator.compile("!foo = \"bar\"")
end
test "returns true if the equality is true" do
assert Predicator.matches?("1 = 1") == true
assert Predicator.matches?("foo = 1", foo: 1) == true
assert Predicator.matches?("!12 = 1") == true
assert Predicator.matches?("!foo = 1", foo: 2) == true
end
test "returns false if the equality is untrue" do
assert Predicator.matches?("12 = 1") == false
assert Predicator.matches?("foo = 1", foo: 2) == false
assert Predicator.matches?("!1 = 1") == false
assert Predicator.matches?("!foo = 1", foo: 1) == false
assert Predicator.matches?("foo = 1", foo: nil) == false
end
end
describe "GT" do
test "compiles atom key instructions" do
assert {:ok, [[:load, :foo], [:lit, 1], [:compare, :GT]]} =
Predicator.compile("foo > 1", :atom_key_inst)
assert {:ok, [[:load, :foo], [:lit, 1], [:compare, :GT], [:not]]} =
Predicator.compile("!foo > 1", :atom_key_inst)
end
test "compiles string key instructions" do
assert {:ok, [["load", "foo"], ["lit", 1], ["compare", "GT"]]} =
Predicator.compile("foo > 1")
assert {:ok, [["load", "foo"], ["lit", 1], ["compare", "GT"], ["not"]]} =
Predicator.compile("!foo > 1")
end
test "returns true if the inequality is true" do
assert Predicator.matches?("3 > 1") == true
assert Predicator.matches?("foo > 1", foo: 2) == true
assert Predicator.matches?("!0 > 1") == true
assert Predicator.matches?("!foo > 1", foo: 0) == true
end
test "returns false if the inequality is untrue" do
assert Predicator.matches?("0 > 1") == false
assert Predicator.matches?("foo > 1", foo: 0) == false
assert Predicator.matches?("foo > 1", foo: nil) == false
assert Predicator.matches?("!3 > 1") == false
assert Predicator.matches?("!foo > 1", foo: 2) == false
end
end
describe "LT" do
test "compiles atom key instructions" do
assert {:ok, [[:load, :foo], [:lit, 1], [:compare, :LT]]} =
Predicator.compile("foo < 1", :atom_key_inst)
assert {:ok, [[:load, :foo], [:lit, 1], [:compare, :LT], [:not]]} =
Predicator.compile("!foo < 1", :atom_key_inst)
end
test "compiles string key instructions" do
assert {:ok, [["load", "foo"], ["lit", 1], ["compare", "LT"]]} =
Predicator.compile("foo < 1")
assert {:ok, [["load", "foo"], ["lit", 1], ["compare", "LT"], ["not"]]} =
Predicator.compile("!foo < 1")
end
test "returns true if the inequality is true" do
assert Predicator.matches?("0 < 1") == true
assert Predicator.matches?("!12 < 1") == true
assert Predicator.matches?("foo < 1", foo: 0) == true
assert Predicator.matches?("!foo < 1", foo: 1) == true
end
test "returns false if the inequality is untrue" do
assert Predicator.matches?("!0 < 1") == false
assert Predicator.matches?("12 < 1") == false
assert Predicator.matches?("!foo < 1", foo: 0) == false
assert Predicator.matches?("foo < 1", foo: 1) == false
assert Predicator.matches?("foo < 1", foo: nil) == false
end
end
describe "IN" do
test "compiles atom key instructions" do
assert {:ok, [[:load, :foo], [:array, [1, 5, 7, 20]], [:compare, :IN]]} =
Predicator.compile("foo in [1, 5, 7, 20]", :atom_key_inst)
assert {:ok, [[:load, :foo], [:array, ["foo", "bar"]], [:compare, :IN]]} =
Predicator.compile("foo in ['foo', 'bar']", :atom_key_inst)
assert {:ok, [[:load, :foo], [:array, ["foo", "bar"]], [:compare, :IN], [:not]]} =
Predicator.compile("!foo in ['foo', 'bar']", :atom_key_inst)
end
test "compiles string key instructions" do
assert {:ok, [["load", "foo"], ["array", [1, 5]], ["compare", "IN"]]} =
Predicator.compile("foo in [1, 5]")
assert {:ok, [["load", "foo"], ["array", ["foo", "bar"]], ["compare", "IN"]]} =
Predicator.compile("foo in ['foo', 'bar']")
assert {:ok, [["load", "foo"], ["array", ["foo", "bar"]], ["compare", "IN"], ["not"]]} =
Predicator.compile("!foo in ['foo', 'bar']")
end
test "returns compilation error when trying to compare to string" do
assert {:error, _error} = Predicator.compile("foo in 'foo'")
assert {:error, _error} = Predicator.compile("foo in 1", :atom_key_inst)
end
test "evaluates to true" do
assert Predicator.matches?("2 in [0, 1, 2, 3]") == true
assert Predicator.matches?("!666 in [0, 1, 2, 3]") == true
assert Predicator.matches?("foo in [0, 1, 2, 3]", foo: 0) == true
assert Predicator.matches?("!foo in [0, 1, 2, 3]", foo: 666) == true
assert Predicator.matches?("foo in ['foo', 'bar']", foo: "foo") == true
assert Predicator.matches?("!foo in ['foo', 'bar']", foo: "foobar") == true
end
test "evaluates to false" do
assert Predicator.matches?("666 in [0, 1, 2, 3]") == false
assert Predicator.matches?("!2 in [0, 1, 2, 3]") == false
assert Predicator.matches?("foo in [0, 1, 2, 3]", foo: 666) == false
assert Predicator.matches?("!foo in [0, 1, 2, 3]", foo: 0) == false
assert Predicator.matches?("foo in ['foo', 'bar']", foo: "foobar") == false
assert Predicator.matches?("!foo in ['foo', 'bar']", foo: "foo") == false
assert Predicator.matches?("foo in ['foo', 'bar']", foo: nil) == false
end
end
describe "NOTIN" do
test "compiles atom key instructions" do
assert {:ok, [[:load, :foo], [:array, [1, 2, 3]], [:compare, :NOTIN]]} =
Predicator.compile("foo not in [1, 2, 3]", :atom_key_inst)
assert {:ok, [[:load, :foo], [:array, ["foo", "bar"]], [:compare, :NOTIN]]} =
Predicator.compile("foo not in ['foo', 'bar']", :atom_key_inst)
assert {:ok, [[:load, :foo], [:array, ["foo", "bar"]], [:compare, :NOTIN], [:not]]} =
Predicator.compile("!foo not in ['foo', 'bar']", :atom_key_inst)
end
test "compiles" do
assert {:ok, [["load", "foo"], ["array", [1, 2, 3]], ["compare", "NOTIN"]]} =
Predicator.compile("foo not in [1, 2, 3]")
assert {:ok, [["load", "foo"], ["array", ["foo", "bar"]], ["compare", "NOTIN"]]} =
Predicator.compile("foo not in ['foo', 'bar']")
assert {:ok, [["load", "foo"], ["array", ["foo", "bar"]], ["compare", "NOTIN"], ["not"]]} =
Predicator.compile("!foo not in ['foo', 'bar']")
end
test "returns compilation error when trying to compare to string" do
assert {:error, _error} = Predicator.compile("!foo in 'foo'")
assert {:error, _error} = Predicator.compile("!foo in 1", :atom_key_inst)
end
test "evaluates to true" do
assert Predicator.matches?("12 not in [1, 2, 3]") == true
assert Predicator.matches?("!2 not in [1, 2, 3]") == true
assert Predicator.matches?("foo not in [1, 2, 3]", foo: 0) == true
assert Predicator.matches?("foo not in ['foo', 'bar']", foo: "foobar") == true
assert Predicator.matches?("!foo not in ['foo', 'bar']", foo: "foo") == true
assert Predicator.matches?("foo not in ['foo', 'bar']", foo: nil) == true
end
test "evaluates to false" do
assert Predicator.matches?("2 not in [1, 2, 3]") == false
assert Predicator.matches?("!12 not in [1, 2, 3]") == false
assert Predicator.matches?("foo not in [1, 2, 3]", foo: 2) == false
assert Predicator.matches?("foo not in ['foo', 'bar']", foo: "foo") == false
assert Predicator.matches?("!foo not in ['foo', 'bar']", foo: "foobar") == false
end
end
describe "AND" do
test "compiles atom key instructions" do
assert {:ok,
[
[:load, :foo],
[:lit, 90],
[:compare, :GT],
[:jfalse, 4],
[:load, :foo],
[:lit, 90],
[:compare, :EQ]
]} = Predicator.compile("foo > 90 and foo = 90", :atom_key_inst)
assert {:ok, [[:lit, true], [:jfalse, 2], [:lit, true], [:not]]} =
Predicator.compile("!true and true", :atom_key_inst)
end
test "compiles string key instructions" do
assert {:ok,
[
["load", "a"],
["lit", 90],
["compare", "GT"],
["jfalse", 4],
["load", "a"],
["lit", 90],
["compare", "EQ"]
]} = Predicator.compile("a > 90 and a = 90")
assert {:ok, [["lit", true], ["jfalse", 2], ["lit", true], ["not"]]} =
Predicator.compile("!true and true")
end
test "evaluates to true" do
assert Predicator.matches?("true and true") == true
assert Predicator.matches?("!true and false") == true
assert Predicator.matches?("foo and foo", foo: true) == true
assert Predicator.matches?("!foo and foo", foo: false) == true
assert Predicator.matches?("foo and foo and foo", foo: true) == true
end
test "evaluates to false" do
assert Predicator.matches?("true and false") == false
assert Predicator.matches?("!true and true") == false
assert Predicator.matches?("true and true and false") == false
assert Predicator.matches?("foo and foo", foo: false) == false
assert Predicator.matches?("!foo and foo", foo: true) == false
assert Predicator.matches?("foo and foo and bar", foo: true, bar: false) == false
end
end
describe "OR" do
test "compiles atom key instructions" do
assert {:ok,
[
[:load, :foo],
[:lit, 90],
[:compare, :GT],
[:jtrue, 4],
[:load, :foo],
[:lit, 90],
[:compare, :EQ]
]} = Predicator.compile("foo > 90 or foo = 90", :atom_key_inst)
assert {:ok, [[:lit, true], [:jtrue, 2], [:lit, false], [:not]]} =
Predicator.compile("!true or false", :atom_key_inst)
end
test "compiles string key instructions" do
assert {:ok,
[
["load", "foo"],
["lit", 90],
["compare", "GT"],
["jtrue", 4],
["load", "foo"],
["lit", 90],
["compare", "EQ"]
]} = Predicator.compile("foo > 90 or foo = 90")
assert {:ok, [["lit", true], ["jtrue", 2], ["lit", false], ["not"]]} =
Predicator.compile("!true or false")
end
test "evaluates to true" do
assert Predicator.matches?("true or true") == true
assert Predicator.matches?("!false or false") == true
assert Predicator.matches?("false or true") == true
assert Predicator.matches?("true or false") == true
assert Predicator.matches?("false or true or false") == true
assert Predicator.matches?("foo or bar", foo: true, bar: false) == true
assert Predicator.matches?("!foo or foo", foo: false) == true
end
test "evaluates to false" do
assert Predicator.matches?("false or false") == false
assert Predicator.matches?("!true or true") == false
assert Predicator.matches?("foo or foo", foo: false) == false
assert Predicator.matches?("foo or bar or foo", foo: false, bar: false) == false
assert Predicator.matches?("!foo or bar", foo: true, bar: false) == false
end
end
describe "JUMP" do
end
describe "PRESENT" do
setup do
%{eval_opts: [map_type: :atom, nil_values: [nil, ""]]}
end
test "compiles atom key instructions" do
assert {:ok, [[:load, :foo], [:present]]} =
Predicator.compile("foo is present", :atom_key_inst)
assert {:ok, [[:load, :foo], [:present], [:not]]} =
Predicator.compile("!foo is present", :atom_key_inst)
end
test "compiles string key instructions" do
assert {:ok, [["load", "foo"], ["present"]]} = Predicator.compile("foo is present")
assert {:ok, [["load", "foo"], ["present"], ["not"]]} =
Predicator.compile("!foo is present")
end
test "evaluates to true", %{eval_opts: eval_opts} do
assert Predicator.matches?("'foo' is present", [], eval_opts) == true
assert Predicator.matches?("!'' is present", [], eval_opts) == true
assert Predicator.matches?("foo is present", [foo: "bar"], eval_opts) == true
assert Predicator.matches?("!foo is present", [foo: ""], eval_opts) == true
end
test "evaluates to false", %{eval_opts: eval_opts} do
assert Predicator.matches?("'' is present", [], eval_opts) == false
assert Predicator.matches?("!'foo' is present", [], eval_opts) == false
assert Predicator.matches?("foo is present", [foo: ""], eval_opts) == false
assert Predicator.matches?("!foo is present", [foo: "bar"], eval_opts) == false
assert Predicator.matches?("foo is present", [foo: nil], eval_opts) == false
end
end
describe "BLANK" do
setup do
%{eval_opts: [map_type: :atom, nil_values: [nil, ""]]}
end
test "compiles atom key instructions" do
assert {:ok, [[:load, :foo], [:blank]]} = Predicator.compile("foo is blank", :atom_key_inst)
assert {:ok, [[:load, :foo], [:blank], [:not]]} =
Predicator.compile("!foo is blank", :atom_key_inst)
end
test "compiles string key instructions" do
assert {:ok, [["load", "foo"], ["blank"]]} = Predicator.compile("foo is blank")
assert {:ok, [["load", "foo"], ["blank"], ["not"]]} = Predicator.compile("!foo is blank")
end
test "evaluates to true", %{eval_opts: eval_opts} do
assert Predicator.matches?("'' is blank", [], eval_opts) == true
assert Predicator.matches?("!'foo' is blank", [], eval_opts) == true
assert Predicator.matches?("foo is blank", [foo: ""], eval_opts) == true
assert Predicator.matches?("!foo is blank", [foo: "bar"], eval_opts) == true
assert Predicator.matches?("foo is blank", [foo: nil], eval_opts) == true
end
test "evaluates to false", %{eval_opts: eval_opts} do
assert Predicator.matches?("'foo' is blank", [], eval_opts) == false
assert Predicator.matches?("!'' is blank", [], eval_opts) == false
assert Predicator.matches?("foo is blank", [foo: "bar"], eval_opts) == false
assert Predicator.matches?("!foo is blank", [foo: ""], eval_opts) == false
end
end
end