predicate 2.8.0 → 2.9.0
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/README.md +17 -0
- data/lib/predicate/asserter.rb +1 -1
- data/lib/predicate/nodes/and.rb +22 -4
- data/lib/predicate/nodes/empty.rb +6 -0
- data/lib/predicate/nodes/eq.rb +4 -0
- data/lib/predicate/nodes/expr.rb +4 -0
- data/lib/predicate/nodes/gt.rb +6 -0
- data/lib/predicate/nodes/gte.rb +6 -0
- data/lib/predicate/nodes/in.rb +12 -0
- data/lib/predicate/nodes/lt.rb +6 -0
- data/lib/predicate/nodes/lte.rb +6 -0
- data/lib/predicate/nodes/neq.rb +11 -0
- data/lib/predicate/nodes/tautology.rb +4 -0
- data/lib/predicate/version.rb +1 -1
- data/lib/predicate.rb +16 -2
- data/spec/factory/shared/a_comparison_factory_method.rb +12 -4
- data/spec/factory/shared/a_predicate_ast_node.rb +11 -5
- data/spec/factory/test_${op_name}.rb.jeny +3 -1
- data/spec/factory/test_and.rb +6 -2
- data/spec/factory/test_comp.rb +27 -9
- data/spec/factory/test_contradiction.rb +3 -1
- data/spec/factory/test_empty.rb +3 -1
- data/spec/factory/test_factor_predicate.rb +21 -7
- data/spec/factory/test_from_hash.rb +21 -7
- data/spec/factory/test_has_size.rb +3 -1
- data/spec/factory/test_identifier.rb +6 -2
- data/spec/factory/test_literal.rb +6 -2
- data/spec/factory/test_match.rb +12 -4
- data/spec/factory/test_native.rb +6 -2
- data/spec/factory/test_not.rb +6 -2
- data/spec/factory/test_or.rb +6 -2
- data/spec/factory/test_qualified_identifier.rb +6 -2
- data/spec/factory/test_set_ops.rb +6 -2
- data/spec/factory/test_tautology.rb +3 -1
- data/spec/factory/test_var.rb +12 -4
- data/spec/grammar/test_match.rb +19 -19
- data/spec/grammar/test_sexpr.rb +49 -17
- data/spec/nodes/and/test_and_split.rb +30 -10
- data/spec/nodes/dyadic_comp/test_and_split.rb +18 -8
- data/spec/nodes/eq/test_and.rb +12 -4
- data/spec/nodes/identifier/test_and_split.rb +6 -2
- data/spec/nodes/identifier/test_free_variables.rb +3 -1
- data/spec/nodes/identifier/test_name.rb +3 -1
- data/spec/nodes/in/test_and.rb +18 -6
- data/spec/nodes/nadic_bool/test_free_variables.rb +3 -1
- data/spec/nodes/or/test_and_split.rb +6 -2
- data/spec/nodes/qualified_identifier/test_and_split.rb +6 -2
- data/spec/nodes/qualified_identifier/test_free_variables.rb +3 -1
- data/spec/nodes/qualified_identifier/test_name.rb +3 -1
- data/spec/nodes/qualified_identifier/test_qualifier.rb +3 -1
- data/spec/predicate/test_and_split.rb +48 -16
- data/spec/predicate/test_assert!.rb +210 -0
- data/spec/predicate/test_attr_split.rb +36 -12
- data/spec/predicate/test_bool_and.rb +7 -3
- data/spec/predicate/test_bool_not.rb +30 -10
- data/spec/predicate/test_bool_or.rb +7 -3
- data/spec/predicate/test_coerce.rb +19 -17
- data/spec/predicate/test_constants.rb +78 -26
- data/spec/predicate/test_free_variables.rb +3 -1
- data/spec/predicate/test_hash_and_equal.rb +7 -3
- data/spec/predicate/test_qualify.rb +8 -6
- data/spec/predicate/test_rename.rb +21 -11
- data/spec/sequel/test_to_sequel.rb +0 -1
- data/spec/shared/a_predicate.rb +8 -8
- data/spec/spec_helper.rb +1 -0
- data/spec/test_readme.rb +1 -1
- metadata +5 -5
data/spec/factory/test_not.rb
CHANGED
@@ -6,8 +6,12 @@ class Predicate
|
|
6
6
|
subject{ self.not(true) }
|
7
7
|
|
8
8
|
it_should_behave_like "a predicate AST node"
|
9
|
-
it{
|
10
|
-
|
9
|
+
it {
|
10
|
+
expect(subject).to be_a(Not)
|
11
|
+
}
|
12
|
+
it {
|
13
|
+
expect(subject).to eql([:not, tautology])
|
14
|
+
}
|
11
15
|
|
12
16
|
end
|
13
17
|
end
|
data/spec/factory/test_or.rb
CHANGED
@@ -6,8 +6,12 @@ class Predicate
|
|
6
6
|
subject{ self.or(true, true) }
|
7
7
|
|
8
8
|
it_should_behave_like "a predicate AST node"
|
9
|
-
it{
|
10
|
-
|
9
|
+
it {
|
10
|
+
expect(subject).to be_a(Or)
|
11
|
+
}
|
12
|
+
it {
|
13
|
+
expect(subject).to eql([:or, tautology, tautology])
|
14
|
+
}
|
11
15
|
|
12
16
|
end
|
13
17
|
end
|
@@ -7,9 +7,13 @@ class Predicate
|
|
7
7
|
|
8
8
|
it_should_behave_like "a predicate AST node"
|
9
9
|
|
10
|
-
it{
|
10
|
+
it{
|
11
|
+
expect(subject).to be_a(QualifiedIdentifier)
|
12
|
+
}
|
11
13
|
|
12
|
-
it{
|
14
|
+
it{
|
15
|
+
expect(subject).to eql([:qualified_identifier, :t, :name])
|
16
|
+
}
|
13
17
|
|
14
18
|
end
|
15
19
|
end
|
@@ -9,9 +9,13 @@ class Predicate
|
|
9
9
|
|
10
10
|
subject{ Factory.send(op_name, :x, [2, 3]) }
|
11
11
|
|
12
|
-
it{
|
12
|
+
it {
|
13
|
+
expect(subject).to be_a(op_class)
|
14
|
+
}
|
13
15
|
|
14
|
-
it{
|
16
|
+
it {
|
17
|
+
expect(subject).to eq([op_name, [:identifier, :x], [:literal, [2, 3]]])
|
18
|
+
}
|
15
19
|
|
16
20
|
end
|
17
21
|
end
|
data/spec/factory/test_var.rb
CHANGED
@@ -7,16 +7,24 @@ class Predicate
|
|
7
7
|
subject{ var("a.b.c", :dig) }
|
8
8
|
|
9
9
|
it_should_behave_like "a predicate AST node"
|
10
|
-
it{
|
11
|
-
|
10
|
+
it {
|
11
|
+
expect(subject).to be_a(Var)
|
12
|
+
}
|
13
|
+
it {
|
14
|
+
expect(subject).to eql([:var, "a.b.c", :dig])
|
15
|
+
}
|
12
16
|
end
|
13
17
|
|
14
18
|
context 'when used with an array' do
|
15
19
|
subject{ var([:a, :b, :c], :dig) }
|
16
20
|
|
17
21
|
it_should_behave_like "a predicate AST node"
|
18
|
-
it{
|
19
|
-
|
22
|
+
it {
|
23
|
+
expect(subject).to be_a(Var)
|
24
|
+
}
|
25
|
+
it {
|
26
|
+
expect(subject).to eql([:var, [:a, :b, :c], :dig])
|
27
|
+
}
|
20
28
|
end
|
21
29
|
end
|
22
30
|
end
|
data/spec/grammar/test_match.rb
CHANGED
@@ -6,10 +6,10 @@ class Predicate
|
|
6
6
|
subject{ Grammar[:tautology] }
|
7
7
|
|
8
8
|
it 'matches a tautology' do
|
9
|
-
subject.
|
9
|
+
expect(subject).to be_match([:tautology, true])
|
10
10
|
end
|
11
11
|
it 'does no match a wrong one' do
|
12
|
-
subject.
|
12
|
+
expect(subject).not_to be_match([:tautology, false])
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -17,10 +17,10 @@ class Predicate
|
|
17
17
|
subject{ Grammar[:contradiction] }
|
18
18
|
|
19
19
|
it 'matches a tautology' do
|
20
|
-
subject.
|
20
|
+
expect(subject).to be_match([:contradiction, false])
|
21
21
|
end
|
22
22
|
it 'does no match a wrong one' do
|
23
|
-
subject.
|
23
|
+
expect(subject).not_to be_match([:contradiction, true])
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -28,11 +28,11 @@ class Predicate
|
|
28
28
|
subject{ Grammar[:identifier] }
|
29
29
|
|
30
30
|
it 'matches a valid ast' do
|
31
|
-
subject.
|
31
|
+
expect(subject).to be_match([:identifier, :id])
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'does not match an invalid ast' do
|
35
|
-
subject.
|
35
|
+
expect(subject).not_to be_match([:identifier, 12])
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -40,8 +40,8 @@ class Predicate
|
|
40
40
|
subject{ Grammar[:literal] }
|
41
41
|
|
42
42
|
it 'matches valid ASTs' do
|
43
|
-
subject.
|
44
|
-
subject.
|
43
|
+
expect(subject).to be_match([:literal, 12])
|
44
|
+
expect(subject).to be_match([:literal, true])
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -49,10 +49,10 @@ class Predicate
|
|
49
49
|
subject{ Grammar[:in] }
|
50
50
|
|
51
51
|
it 'matches valid ASTs' do
|
52
|
-
subject.
|
52
|
+
expect(subject).to be_match([:in, [:identifier, :x], [2, 3]])
|
53
53
|
end
|
54
54
|
it 'does not match invalid ASTs' do
|
55
|
-
subject.
|
55
|
+
expect(subject).not_to be_match([:in, :x])
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -60,10 +60,10 @@ class Predicate
|
|
60
60
|
subject{ Grammar[:eq] }
|
61
61
|
|
62
62
|
it 'matches valid ASTs' do
|
63
|
-
subject.
|
63
|
+
expect(subject).to be_match([:eq, [:identifier, :age], [:literal, 12]])
|
64
64
|
end
|
65
65
|
it 'does not match invalid ASTs' do
|
66
|
-
subject.
|
66
|
+
expect(subject).not_to be_match([:neq, [:identifier, :age], [:literal, 12]])
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -71,10 +71,10 @@ class Predicate
|
|
71
71
|
subject{ Grammar[:neq] }
|
72
72
|
|
73
73
|
it 'matches valid ASTs' do
|
74
|
-
subject.
|
74
|
+
expect(subject).to be_match([:neq, [:identifier, :age], [:literal, 12]])
|
75
75
|
end
|
76
76
|
it 'does not match invalid ASTs' do
|
77
|
-
subject.
|
77
|
+
expect(subject).not_to be_match([:eq, [:identifier, :age], [:literal, 12]])
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -82,11 +82,11 @@ class Predicate
|
|
82
82
|
subject{ Grammar[:match] }
|
83
83
|
|
84
84
|
it 'matches valid ASTs' do
|
85
|
-
subject.
|
86
|
-
subject.
|
85
|
+
expect(subject).to be_match([:match, [:identifier, :name], [:literal, "London"], {}])
|
86
|
+
expect(subject).to be_match([:match, [:identifier, :name], [:literal, /London/], {}])
|
87
87
|
end
|
88
88
|
it 'does not match invalid ASTs' do
|
89
|
-
subject.
|
89
|
+
expect(subject).not_to be_match([:native, 12])
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -94,10 +94,10 @@ class Predicate
|
|
94
94
|
subject{ Grammar[:native] }
|
95
95
|
|
96
96
|
it 'matches valid ASTs' do
|
97
|
-
subject.
|
97
|
+
expect(subject).to be_match([:native, lambda{}])
|
98
98
|
end
|
99
99
|
it 'does not match invalid ASTs' do
|
100
|
-
subject.
|
100
|
+
expect(subject).not_to be_match([:native, 12])
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
data/spec/grammar/test_sexpr.rb
CHANGED
@@ -17,103 +17,135 @@ class Predicate
|
|
17
17
|
}
|
18
18
|
|
19
19
|
before do
|
20
|
-
subject.
|
20
|
+
expect(subject).to be_a(Sexpr)
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "tautology" do
|
24
24
|
let(:expr){ [:tautology, true] }
|
25
25
|
|
26
|
-
it{
|
26
|
+
it {
|
27
|
+
expect(subject).to be_a(Tautology)
|
28
|
+
}
|
27
29
|
end
|
28
30
|
|
29
31
|
describe "contradiction" do
|
30
32
|
let(:expr){ [:contradiction, false] }
|
31
33
|
|
32
|
-
it{
|
34
|
+
it {
|
35
|
+
expect(subject).to be_a(Contradiction)
|
36
|
+
}
|
33
37
|
end
|
34
38
|
|
35
39
|
describe "identifier" do
|
36
40
|
let(:expr){ [:identifier, :name] }
|
37
41
|
|
38
|
-
it{
|
42
|
+
it {
|
43
|
+
expect(subject).to be_a(Identifier)
|
44
|
+
}
|
39
45
|
end
|
40
46
|
|
41
47
|
describe "and" do
|
42
48
|
let(:expr){ [:and, contradiction, contradiction] }
|
43
49
|
|
44
|
-
it{
|
50
|
+
it {
|
51
|
+
expect(subject).to be_a(And)
|
52
|
+
}
|
45
53
|
end
|
46
54
|
|
47
55
|
describe "or" do
|
48
56
|
let(:expr){ [:or, contradiction, contradiction] }
|
49
57
|
|
50
|
-
it{
|
58
|
+
it {
|
59
|
+
expect(subject).to be_a(Or)
|
60
|
+
}
|
51
61
|
end
|
52
62
|
|
53
63
|
describe "not" do
|
54
64
|
let(:expr){ [:not, contradiction] }
|
55
65
|
|
56
|
-
it{
|
66
|
+
it {
|
67
|
+
expect(subject).to be_a(Not)
|
68
|
+
}
|
57
69
|
end
|
58
70
|
|
59
71
|
describe "eq" do
|
60
72
|
let(:expr){ [:eq, identifier, identifier] }
|
61
73
|
|
62
|
-
it{
|
74
|
+
it {
|
75
|
+
expect(subject).to be_a(Eq)
|
76
|
+
}
|
63
77
|
end
|
64
78
|
|
65
79
|
describe "neq" do
|
66
80
|
let(:expr){ [:neq, identifier, identifier] }
|
67
81
|
|
68
|
-
it{
|
82
|
+
it {
|
83
|
+
expect(subject).to be_a(Neq)
|
84
|
+
}
|
69
85
|
end
|
70
86
|
|
71
87
|
describe "gt" do
|
72
88
|
let(:expr){ [:gt, identifier, identifier] }
|
73
89
|
|
74
|
-
it{
|
90
|
+
it {
|
91
|
+
expect(subject).to be_a(Gt)
|
92
|
+
}
|
75
93
|
end
|
76
94
|
|
77
95
|
describe "gte" do
|
78
96
|
let(:expr){ [:gte, identifier, identifier] }
|
79
97
|
|
80
|
-
it{
|
98
|
+
it {
|
99
|
+
expect(subject).to be_a(Gte)
|
100
|
+
}
|
81
101
|
end
|
82
102
|
|
83
103
|
describe "lt" do
|
84
104
|
let(:expr){ [:lt, identifier, identifier] }
|
85
105
|
|
86
|
-
it{
|
106
|
+
it {
|
107
|
+
expect(subject).to be_a(Lt)
|
108
|
+
}
|
87
109
|
end
|
88
110
|
|
89
111
|
describe "lte" do
|
90
112
|
let(:expr){ [:lte, identifier, identifier] }
|
91
113
|
|
92
|
-
it{
|
114
|
+
it {
|
115
|
+
expect(subject).to be_a(Lte)
|
116
|
+
}
|
93
117
|
end
|
94
118
|
|
95
119
|
describe "in" do
|
96
120
|
let(:expr){ [:in, identifier, values] }
|
97
121
|
|
98
|
-
it{
|
122
|
+
it {
|
123
|
+
expect(subject).to be_a(In)
|
124
|
+
}
|
99
125
|
end
|
100
126
|
|
101
127
|
describe "intersect" do
|
102
128
|
let(:expr){ [:intersect, identifier, values] }
|
103
129
|
|
104
|
-
it{
|
130
|
+
it {
|
131
|
+
expect(subject).to be_a(Intersect)
|
132
|
+
}
|
105
133
|
end
|
106
134
|
|
107
135
|
describe "literal" do
|
108
136
|
let(:expr){ [:literal, 12] }
|
109
137
|
|
110
|
-
it{
|
138
|
+
it {
|
139
|
+
expect(subject).to be_a(Literal)
|
140
|
+
}
|
111
141
|
end
|
112
142
|
|
113
143
|
describe "native" do
|
114
144
|
let(:expr){ [:native, lambda{}] }
|
115
145
|
|
116
|
-
it{
|
146
|
+
it {
|
147
|
+
expect(subject).to be_a(Native)
|
148
|
+
}
|
117
149
|
end
|
118
150
|
|
119
151
|
end
|
@@ -12,19 +12,25 @@ class Predicate
|
|
12
12
|
context 'when fully covered' do
|
13
13
|
let(:list){ [:x, :y] }
|
14
14
|
|
15
|
-
it{
|
15
|
+
it {
|
16
|
+
expect(subject).to eq([predicate, tautology])
|
17
|
+
}
|
16
18
|
end
|
17
19
|
|
18
20
|
context 'when not covered at all' do
|
19
21
|
let(:list){ [:name] }
|
20
22
|
|
21
|
-
it{
|
23
|
+
it {
|
24
|
+
expect(subject).to eq([tautology, predicate])
|
25
|
+
}
|
22
26
|
end
|
23
27
|
|
24
28
|
context 'when partially covered' do
|
25
29
|
let(:list){ [:x] }
|
26
30
|
|
27
|
-
it{
|
31
|
+
it {
|
32
|
+
expect(subject).to eq([Factory.eq(:x, 2), Factory.eq(:y, 3)])
|
33
|
+
}
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
@@ -34,31 +40,41 @@ class Predicate
|
|
34
40
|
context 'when fully covered' do
|
35
41
|
let(:list){ [:x, :y, :z] }
|
36
42
|
|
37
|
-
it{
|
43
|
+
it {
|
44
|
+
expect(subject).to eq([predicate, tautology])
|
45
|
+
}
|
38
46
|
end
|
39
47
|
|
40
48
|
context 'when not covered at all' do
|
41
49
|
let(:list){ [:name] }
|
42
50
|
|
43
|
-
it{
|
51
|
+
it {
|
52
|
+
expect(subject).to eq([tautology, predicate])
|
53
|
+
}
|
44
54
|
end
|
45
55
|
|
46
56
|
context 'when partially covered but split-able' do
|
47
57
|
let(:list){ [:x] }
|
48
58
|
|
49
|
-
it{
|
59
|
+
it {
|
60
|
+
expect(subject).to eq([Factory.eq(:x, 2), Factory.eq(:y, :z)])
|
61
|
+
}
|
50
62
|
end
|
51
63
|
|
52
64
|
context 'when partially covered but split-able (2)' do
|
53
65
|
let(:list){ [:y] }
|
54
66
|
|
55
|
-
it{
|
67
|
+
it {
|
68
|
+
expect(subject).to eq([Factory.eq(:y, :z), Factory.eq(:x, 2)])
|
69
|
+
}
|
56
70
|
end
|
57
71
|
|
58
72
|
context 'when partially covered but not split-able' do
|
59
73
|
let(:list){ [:x, :y] }
|
60
74
|
|
61
|
-
it{
|
75
|
+
it {
|
76
|
+
expect(subject).to eq([predicate, tautology])
|
77
|
+
}
|
62
78
|
end
|
63
79
|
end
|
64
80
|
|
@@ -70,13 +86,17 @@ class Predicate
|
|
70
86
|
context 'when fully covered' do
|
71
87
|
let(:list){ [:x, :y, :z] }
|
72
88
|
|
73
|
-
it{
|
89
|
+
it {
|
90
|
+
expect(subject).to eq([predicate, tautology])
|
91
|
+
}
|
74
92
|
end
|
75
93
|
|
76
94
|
context 'when not covered' do
|
77
95
|
let(:list){ [:y] }
|
78
96
|
|
79
|
-
it{
|
97
|
+
it {
|
98
|
+
expect(subject).to eq([right, left])
|
99
|
+
}
|
80
100
|
end
|
81
101
|
end
|
82
102
|
|
@@ -10,13 +10,17 @@ class Predicate
|
|
10
10
|
context 'when included' do
|
11
11
|
let(:list){ [:id, :name] }
|
12
12
|
|
13
|
-
it{
|
13
|
+
it {
|
14
|
+
expect(subject).to eq([predicate, tautology])
|
15
|
+
}
|
14
16
|
end
|
15
17
|
|
16
18
|
context 'when not include' do
|
17
19
|
let(:list){ [:name] }
|
18
20
|
|
19
|
-
it{
|
21
|
+
it {
|
22
|
+
expect(subject).to eq([tautology, predicate])
|
23
|
+
}
|
20
24
|
end
|
21
25
|
|
22
26
|
context 'with attributes on both sides' do
|
@@ -24,20 +28,26 @@ class Predicate
|
|
24
28
|
|
25
29
|
context 'when full at left' do
|
26
30
|
let(:list){ [:x, :y] }
|
27
|
-
|
28
|
-
it{
|
31
|
+
|
32
|
+
it {
|
33
|
+
expect(subject).to eq([predicate, tautology])
|
34
|
+
}
|
29
35
|
end
|
30
|
-
|
36
|
+
|
31
37
|
context 'none at left' do
|
32
38
|
let(:list){ [] }
|
33
|
-
|
34
|
-
it{
|
39
|
+
|
40
|
+
it {
|
41
|
+
expect(subject).to eq([tautology, predicate])
|
42
|
+
}
|
35
43
|
end
|
36
44
|
|
37
45
|
context 'mix' do
|
38
46
|
let(:list){ [:y] }
|
39
47
|
|
40
|
-
it{
|
48
|
+
it {
|
49
|
+
expect(subject).to eq([predicate, tautology])
|
50
|
+
}
|
41
51
|
end
|
42
52
|
end
|
43
53
|
|
data/spec/nodes/eq/test_and.rb
CHANGED
@@ -11,25 +11,33 @@ class Predicate
|
|
11
11
|
context 'with an eq leading to a contradiction' do
|
12
12
|
let(:right){ Factory.eq(:x, 3) }
|
13
13
|
|
14
|
-
it{
|
14
|
+
it{
|
15
|
+
expect(subject).to be_a(Contradiction)
|
16
|
+
}
|
15
17
|
end
|
16
18
|
|
17
19
|
context 'with an IN on same variable and literal' do
|
18
20
|
let(:right){ Factory.in(:x, [2,4]) }
|
19
21
|
|
20
|
-
it{
|
22
|
+
it{
|
23
|
+
expect(subject).to be(left)
|
24
|
+
}
|
21
25
|
end
|
22
26
|
|
23
27
|
context 'with an IN on same variable and opaque' do
|
24
28
|
let(:right){ Factory.in(:x, Factory.opaque([3,4])) }
|
25
29
|
|
26
|
-
it{
|
30
|
+
it{
|
31
|
+
expect(subject).to be_a(And)
|
32
|
+
}
|
27
33
|
end
|
28
34
|
|
29
35
|
context 'with an IN having a placeholder' do
|
30
36
|
let(:right){ Factory.in(:x, Factory.placeholder) }
|
31
37
|
|
32
|
-
it{
|
38
|
+
it{
|
39
|
+
expect(subject).to be_a(And)
|
40
|
+
}
|
33
41
|
end
|
34
42
|
|
35
43
|
end
|
@@ -10,13 +10,17 @@ class Predicate
|
|
10
10
|
context 'when included' do
|
11
11
|
let(:list){ [:id, :name] }
|
12
12
|
|
13
|
-
it{
|
13
|
+
it {
|
14
|
+
expect(subject).to eq([predicate, tautology])
|
15
|
+
}
|
14
16
|
end
|
15
17
|
|
16
18
|
context 'when not include' do
|
17
19
|
let(:list){ [:name] }
|
18
20
|
|
19
|
-
it{
|
21
|
+
it {
|
22
|
+
expect(subject).to eq([tautology, predicate])
|
23
|
+
}
|
20
24
|
end
|
21
25
|
|
22
26
|
end
|
data/spec/nodes/in/test_and.rb
CHANGED
@@ -11,37 +11,49 @@ class Predicate
|
|
11
11
|
context 'with an eq on same variable' do
|
12
12
|
let(:right){ Factory.eq(:x, 2) }
|
13
13
|
|
14
|
-
it{
|
14
|
+
it {
|
15
|
+
expect(subject).to be(right)
|
16
|
+
}
|
15
17
|
end
|
16
18
|
|
17
19
|
context 'with an eq on same variable yielding a contradiction' do
|
18
20
|
let(:right){ Factory.eq(:x, 3) }
|
19
21
|
|
20
|
-
it{
|
22
|
+
it {
|
23
|
+
expect(subject).to eql(Factory.contradiction)
|
24
|
+
}
|
21
25
|
end
|
22
26
|
|
23
27
|
context 'with an in on same variable' do
|
24
28
|
let(:right){ Factory.in(:x, [2, 4, 5]) }
|
25
29
|
|
26
|
-
it{
|
30
|
+
it {
|
31
|
+
expect(subject).to eql(Factory.in(:x, [2, 4]))
|
32
|
+
}
|
27
33
|
end
|
28
34
|
|
29
35
|
context 'with an in on same variable, leading to a singleton' do
|
30
36
|
let(:right){ Factory.in(:x, [2]) }
|
31
37
|
|
32
|
-
it{
|
38
|
+
it {
|
39
|
+
expect(subject).to eql(Factory.eq(:x, 2))
|
40
|
+
}
|
33
41
|
end
|
34
42
|
|
35
43
|
context 'with an eq on same variable, leading to a singleton' do
|
36
44
|
let(:right){ Factory.in(:x, [2, 5]) }
|
37
45
|
|
38
|
-
it{
|
46
|
+
it {
|
47
|
+
expect(subject).to eql(Factory.eq(:x, 2))
|
48
|
+
}
|
39
49
|
end
|
40
50
|
|
41
51
|
context 'with an in on same variable, leading to a empty set' do
|
42
52
|
let(:right){ Factory.in(:x, [5]) }
|
43
53
|
|
44
|
-
it{
|
54
|
+
it {
|
55
|
+
expect(subject).to eql(Factory.contradiction)
|
56
|
+
}
|
45
57
|
end
|
46
58
|
|
47
59
|
end
|