logic 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/logic_operations.rb +6 -1
- data/lib/logic_parser.treetop +2 -0
- data/lib/test_case_set.rb +1 -0
- data/spec/logic_parser_spec.rb +6 -10
- data/spec/test_case_set_spec.rb +0 -2
- metadata +2 -2
data/lib/logic_operations.rb
CHANGED
data/lib/logic_parser.treetop
CHANGED
data/lib/test_case_set.rb
CHANGED
data/spec/logic_parser_spec.rb
CHANGED
@@ -8,48 +8,38 @@ describe LogicParser, :parsing do
|
|
8
8
|
let(:parser) { LogicParser.new }
|
9
9
|
|
10
10
|
describe "a single condition" do
|
11
|
-
|
12
11
|
it "identifies the condition" do
|
13
12
|
decision = parser.parse('Hello')
|
14
13
|
decision.condition_identifiers.should == ['Hello']
|
15
14
|
end
|
16
|
-
|
17
15
|
end
|
18
16
|
|
19
17
|
describe "'A or B'" do
|
20
|
-
|
21
18
|
it "condition identifiers are ['A','B']" do
|
22
19
|
decision = parser.parse('A or B')
|
23
20
|
decision.condition_identifiers.should == ['A','B']
|
24
21
|
end
|
25
|
-
|
26
22
|
end
|
27
23
|
|
28
24
|
describe "'A or B or C'" do
|
29
|
-
|
30
25
|
it "condition identifiers are ['A','B','C']" do
|
31
26
|
decision = parser.parse('A or B or C')
|
32
27
|
decision.condition_identifiers.should == ['A','B','C']
|
33
28
|
end
|
34
|
-
|
35
29
|
end
|
36
30
|
|
37
31
|
describe "'A and B'" do
|
38
|
-
|
39
32
|
it "conditions are ['A','B']" do
|
40
33
|
decision = parser.parse('A and B')
|
41
34
|
decision.condition_identifiers.should == ['A','B']
|
42
35
|
end
|
43
|
-
|
44
36
|
end
|
45
37
|
|
46
38
|
describe "'A and B and C'" do
|
47
|
-
|
48
39
|
it "condition identifiers are ['A','B','C']" do
|
49
40
|
decision = parser.parse('A and B and C')
|
50
41
|
decision.condition_identifiers.should == ['A','B','C']
|
51
42
|
end
|
52
|
-
|
53
43
|
end
|
54
44
|
|
55
45
|
{ 'Hello' =>
|
@@ -69,6 +59,12 @@ describe LogicParser, :parsing do
|
|
69
59
|
[0, 1] => 1,
|
70
60
|
[1, 0] => 1
|
71
61
|
},
|
62
|
+
'A xor B' =>
|
63
|
+
{ [0, 0] => 0,
|
64
|
+
[0, 1] => 1,
|
65
|
+
[1, 0] => 1,
|
66
|
+
[1, 1] => 0
|
67
|
+
},
|
72
68
|
'A and B' =>
|
73
69
|
{ [1, 1] => 1,
|
74
70
|
[0, 1] => 0,
|
data/spec/test_case_set_spec.rb
CHANGED
@@ -3,12 +3,10 @@ require 'test_case_set'
|
|
3
3
|
describe TestCaseSet do
|
4
4
|
|
5
5
|
describe "with 1 condition" do
|
6
|
-
|
7
6
|
it "input_dentifiers includes 'a'" do
|
8
7
|
test_case_set = TestCaseSet.new(['hello'], nil)
|
9
8
|
test_case_set.input_identifiers.should include('a')
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
13
11
|
|
14
12
|
end
|