logic 0.1.3 → 0.1.4
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/LICENSE +4 -4
- data/README.rdoc +11 -2
- data/lib/logic_parser.treetop +7 -10
- data/lib/test_case.rb +0 -1
- data/spec/logic_parser_spec.rb +53 -11
- data/spec/test_case_set_spec.rb +1 -3
- metadata +45 -17
- data/lib/symbol.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11e5edf39c29218f130ec320ef00c7b883eb6800
|
4
|
+
data.tar.gz: 86a38a736d41e8801598678e4be7ac2639725b29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd9a8d5026c1011747cb33bd5f0bec1981c3054bc0cbcd4d02de8937c586bdf7cda367ae0b44da181f28cea3c44121f2b82dbc0e2ec3d5a233d07f58ea15d3fb
|
7
|
+
data.tar.gz: 067073560f67447e7bb195232ed9b149b3a93eb1e35d9bad6f0ca76e423e49d329d4ba9d7bf1c110236b4e63b70686d49c1915116dd17af3a2d0469e57bb2cba
|
data/LICENSE
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
Copyright (c)
|
2
|
-
|
1
|
+
Copyright (c) 2017 Bryan Ash
|
2
|
+
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
5
5
|
"Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@ without limitation the rights to use, copy, modify, merge, publish,
|
|
7
7
|
distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
the following conditions:
|
10
|
-
|
10
|
+
|
11
11
|
The above copyright notice and this permission notice shall be
|
12
12
|
included in all copies or substantial portions of the Software.
|
13
|
-
|
13
|
+
|
14
14
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
data/README.rdoc
CHANGED
@@ -8,10 +8,15 @@
|
|
8
8
|
|
9
9
|
By default, you get a truth table and a list of MC/DC pairs:
|
10
10
|
|
11
|
-
logic '(
|
11
|
+
logic '(apple or bongo) and (cat or dog)'
|
12
12
|
|
13
13
|
Gives you:
|
14
14
|
|
15
|
+
a <= apple
|
16
|
+
b <= bongo
|
17
|
+
c <= cat
|
18
|
+
d <= dog
|
19
|
+
|
15
20
|
a b c d | output
|
16
21
|
1) 0 0 0 0 | 0
|
17
22
|
2) 0 0 0 1 | 0
|
@@ -35,6 +40,10 @@ Gives you:
|
|
35
40
|
c => [[5, 7], [9, 11], [13, 15]]
|
36
41
|
d => [[5, 6], [9, 10], [13, 14]]
|
37
42
|
|
43
|
+
== Operators
|
44
|
+
|
45
|
+
The syntax understands: 'and', '&&', 'or', '||', 'xor', '^', 'not', '!', and parenthesis.
|
46
|
+
|
38
47
|
== Copyright
|
39
48
|
|
40
|
-
Copyright (c)
|
49
|
+
Copyright (c) 2017 Bryan Ash. See LICENSE for details.
|
data/lib/logic_parser.treetop
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
grammar Logic
|
2
|
-
|
3
2
|
rule decision
|
4
3
|
binary_decision / unary_decision
|
5
4
|
end
|
6
5
|
|
7
6
|
rule binary_decision
|
8
|
-
operand_1:unary_decision
|
9
|
-
operator
|
7
|
+
operand_1:unary_decision
|
8
|
+
operator
|
10
9
|
operand_2:decision <BinaryDecision>
|
11
10
|
end
|
12
11
|
|
@@ -15,12 +14,11 @@ grammar Logic
|
|
15
14
|
end
|
16
15
|
|
17
16
|
rule negation
|
18
|
-
space?
|
19
|
-
'not' space operand:unary_decision <Negation>
|
17
|
+
('not' space / '!' space?) operand:unary_decision <Negation>
|
20
18
|
end
|
21
19
|
|
22
20
|
rule condition
|
23
|
-
[A-Za-
|
21
|
+
[A-Za-z_]+ <Condition>
|
24
22
|
end
|
25
23
|
|
26
24
|
rule parenthesized
|
@@ -28,15 +26,14 @@ grammar Logic
|
|
28
26
|
end
|
29
27
|
|
30
28
|
rule operator
|
31
|
-
'and' <And>
|
29
|
+
(space 'and' space / space? '&&' space?) <And>
|
32
30
|
/
|
33
|
-
'or' <Or>
|
31
|
+
(space 'or' space / space? '||' space?) <Or>
|
34
32
|
/
|
35
|
-
'xor' <Xor>
|
33
|
+
(space 'xor' space / space? '^' space?) <Xor>
|
36
34
|
end
|
37
35
|
|
38
36
|
rule space
|
39
37
|
[ \t\n\r]+
|
40
38
|
end
|
41
|
-
|
42
39
|
end
|
data/lib/test_case.rb
CHANGED
data/spec/logic_parser_spec.rb
CHANGED
@@ -4,41 +4,45 @@ require 'logic_parser'
|
|
4
4
|
require 'logic_operations'
|
5
5
|
|
6
6
|
describe LogicParser, :parsing do
|
7
|
-
|
8
7
|
let(:parser) { LogicParser.new }
|
9
8
|
|
10
9
|
describe "a single condition" do
|
11
10
|
it "identifies the condition" do
|
12
11
|
decision = parser.parse('Hello')
|
13
|
-
decision.condition_identifiers.
|
12
|
+
expect(decision.condition_identifiers).to eq ['Hello']
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'allows underscores in the condition' do
|
16
|
+
decision = parser.parse('a_name')
|
17
|
+
expect(decision.condition_identifiers).to eq ['a_name']
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
17
21
|
describe "'A or B'" do
|
18
22
|
it "condition identifiers are ['A','B']" do
|
19
23
|
decision = parser.parse('A or B')
|
20
|
-
decision.condition_identifiers.
|
24
|
+
expect(decision.condition_identifiers).to eq ['A','B']
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
28
|
describe "'A or B or C'" do
|
25
29
|
it "condition identifiers are ['A','B','C']" do
|
26
30
|
decision = parser.parse('A or B or C')
|
27
|
-
decision.condition_identifiers.
|
31
|
+
expect(decision.condition_identifiers).to eq ['A','B','C']
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
35
|
describe "'A and B'" do
|
32
36
|
it "conditions are ['A','B']" do
|
33
37
|
decision = parser.parse('A and B')
|
34
|
-
decision.condition_identifiers.
|
38
|
+
expect(decision.condition_identifiers).to eq ['A','B']
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
42
|
describe "'A and B and C'" do
|
39
43
|
it "condition identifiers are ['A','B','C']" do
|
40
44
|
decision = parser.parse('A and B and C')
|
41
|
-
decision.condition_identifiers.
|
45
|
+
expect(decision.condition_identifiers).to eq ['A','B','C']
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
@@ -50,7 +54,11 @@ describe LogicParser, :parsing do
|
|
50
54
|
{ [0] => 0,
|
51
55
|
[1] => 1
|
52
56
|
},
|
53
|
-
'
|
57
|
+
'not negated' =>
|
58
|
+
{ [0] => 1,
|
59
|
+
[1] => 0
|
60
|
+
},
|
61
|
+
'!negated' =>
|
54
62
|
{ [0] => 1,
|
55
63
|
[1] => 0
|
56
64
|
},
|
@@ -59,17 +67,54 @@ describe LogicParser, :parsing do
|
|
59
67
|
[0, 1] => 1,
|
60
68
|
[1, 0] => 1
|
61
69
|
},
|
70
|
+
'A || B' =>
|
71
|
+
{ [0, 0] => 0,
|
72
|
+
[0, 1] => 1,
|
73
|
+
[1, 0] => 1
|
74
|
+
},
|
75
|
+
'A||B' =>
|
76
|
+
{ [0, 0] => 0,
|
77
|
+
[0, 1] => 1,
|
78
|
+
[1, 0] => 1
|
79
|
+
},
|
62
80
|
'A xor B' =>
|
63
81
|
{ [0, 0] => 0,
|
64
82
|
[0, 1] => 1,
|
65
83
|
[1, 0] => 1,
|
66
84
|
[1, 1] => 0
|
67
85
|
},
|
86
|
+
'A ^ B' =>
|
87
|
+
{ [0, 0] => 0,
|
88
|
+
[0, 1] => 1,
|
89
|
+
[1, 0] => 1,
|
90
|
+
[1, 1] => 0
|
91
|
+
},
|
92
|
+
'A^B' =>
|
93
|
+
{ [0, 0] => 0,
|
94
|
+
[0, 1] => 1,
|
95
|
+
[1, 0] => 1,
|
96
|
+
[1, 1] => 0
|
97
|
+
},
|
68
98
|
'A and B' =>
|
69
99
|
{ [1, 1] => 1,
|
70
100
|
[0, 1] => 0,
|
71
101
|
[1, 0] => 0
|
72
102
|
},
|
103
|
+
'A && B' =>
|
104
|
+
{ [1, 1] => 1,
|
105
|
+
[0, 1] => 0,
|
106
|
+
[1, 0] => 0
|
107
|
+
},
|
108
|
+
'A&&B' =>
|
109
|
+
{ [1, 1] => 1,
|
110
|
+
[0, 1] => 0,
|
111
|
+
[1, 0] => 0
|
112
|
+
},
|
113
|
+
'A and not B' =>
|
114
|
+
{ [1, 1] => 0,
|
115
|
+
[0, 1] => 0,
|
116
|
+
[1, 0] => 1
|
117
|
+
},
|
73
118
|
'A or B or C' =>
|
74
119
|
{ [0, 0, 0] => 0,
|
75
120
|
[1, 0, 0] => 1,
|
@@ -102,15 +147,12 @@ describe LogicParser, :parsing do
|
|
102
147
|
}
|
103
148
|
}.each do |logic, cases|
|
104
149
|
describe "'#{logic}'" do
|
105
|
-
|
106
150
|
cases.each do |conditions, result|
|
107
151
|
it "'#{conditions}' evaluates to '#{result}'" do
|
108
152
|
decision = parser.parse(logic)
|
109
|
-
decision.evaluate(conditions).
|
153
|
+
expect(decision.evaluate(conditions)).to eq result
|
110
154
|
end
|
111
155
|
end
|
112
156
|
end
|
113
|
-
|
114
157
|
end
|
115
|
-
|
116
158
|
end
|
data/spec/test_case_set_spec.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'test_case_set'
|
2
2
|
|
3
3
|
describe TestCaseSet do
|
4
|
-
|
5
4
|
describe "with 1 condition" do
|
6
5
|
it "input_dentifiers includes 'a'" do
|
7
6
|
test_case_set = TestCaseSet.new(['hello'], nil)
|
8
|
-
test_case_set.input_identifiers.
|
7
|
+
expect(test_case_set.input_identifiers).to include('a')
|
9
8
|
end
|
10
9
|
end
|
11
|
-
|
12
10
|
end
|
metadata
CHANGED
@@ -1,45 +1,73 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Ash
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.6.8
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.6.8
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: aruba
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2
|
34
|
-
type: :
|
33
|
+
version: 0.14.2
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.14.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: cucumber
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.4.0
|
48
|
+
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
54
|
+
version: 2.4.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.5.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.5.0
|
41
69
|
description: Produces truth table and MC/DC test case pairs from parsed logic statement
|
42
|
-
email:
|
70
|
+
email: bryan.a.ash@gmail.com
|
43
71
|
executables:
|
44
72
|
- logic
|
45
73
|
extensions: []
|
@@ -55,7 +83,6 @@ files:
|
|
55
83
|
- lib/logic_operations.rb
|
56
84
|
- lib/logic_parser.treetop
|
57
85
|
- lib/range.rb
|
58
|
-
- lib/symbol.rb
|
59
86
|
- lib/test_case.rb
|
60
87
|
- lib/test_case_set.rb
|
61
88
|
- lib/truth_table.rb
|
@@ -63,7 +90,8 @@ files:
|
|
63
90
|
- spec/spec.opts
|
64
91
|
- spec/test_case_set_spec.rb
|
65
92
|
homepage:
|
66
|
-
licenses:
|
93
|
+
licenses:
|
94
|
+
- MIT
|
67
95
|
metadata: {}
|
68
96
|
post_install_message:
|
69
97
|
rdoc_options:
|
@@ -79,10 +107,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
107
|
requirements:
|
80
108
|
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
110
|
+
version: 1.3.6
|
83
111
|
requirements: []
|
84
112
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.5.1
|
86
114
|
signing_key:
|
87
115
|
specification_version: 4
|
88
116
|
summary: Taking the pain out of MC/DC testing
|