logic 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/logic +21 -43
- metadata +3 -3
data/bin/logic
CHANGED
@@ -1,61 +1,39 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/../lib")
|
3
3
|
|
4
|
+
require 'optparse'
|
4
5
|
require 'rubygems'
|
5
6
|
require 'treetop'
|
6
7
|
require 'logic_parser'
|
7
8
|
require 'logic_operations'
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
options = {}
|
11
|
+
|
12
|
+
option_parser = OptionParser.new
|
12
13
|
|
13
|
-
|
14
|
+
option_parser.banner = "Usage: logic [options] <decision>"
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
a b c d | output
|
20
|
-
1) 0 0 0 0 | 0
|
21
|
-
2) 0 0 0 1 | 0
|
22
|
-
3) 0 0 1 0 | 0
|
23
|
-
4) 0 0 1 1 | 0
|
24
|
-
5) 0 1 0 0 | 0
|
25
|
-
6) 0 1 0 1 | 1
|
26
|
-
7) 0 1 1 0 | 1
|
27
|
-
8) 0 1 1 1 | 1
|
28
|
-
9) 1 0 0 0 | 0
|
29
|
-
10) 1 0 0 1 | 1
|
30
|
-
11) 1 0 1 0 | 1
|
31
|
-
12) 1 0 1 1 | 1
|
32
|
-
13) 1 1 0 0 | 0
|
33
|
-
14) 1 1 0 1 | 1
|
34
|
-
15) 1 1 1 0 | 1
|
35
|
-
16) 1 1 1 1 | 1
|
36
|
-
|
37
|
-
MC/DC test case pairs can also be found:
|
16
|
+
option_parser.on( '-l', '--truth_table', 'Show the truth table for the decision' ) do
|
17
|
+
options[:truth_table] = true
|
18
|
+
end
|
38
19
|
|
39
|
-
|
20
|
+
option_parser.on( '-m', '--mcdc_pairs', 'Show MC/DC test case pairs' ) do
|
21
|
+
options[:mcdc_pairs] = true
|
22
|
+
end
|
40
23
|
|
41
|
-
|
24
|
+
option_parser.on( '-h', '--help', 'You\'re looking at it' ) do
|
25
|
+
options[:help] = true
|
26
|
+
end
|
42
27
|
|
43
|
-
|
44
|
-
b => [[2, 6], [3, 7], [4, 8]]
|
45
|
-
c => [[5, 7], [9, 11], [13, 15]]
|
46
|
-
d => [[5, 6], [9, 10], [13, 14]]
|
28
|
+
option_parser.parse!
|
47
29
|
|
48
|
-
|
49
|
-
|
30
|
+
if options[:help] or ARGV.length == 0
|
31
|
+
puts option_parser.help
|
32
|
+
exit
|
50
33
|
end
|
51
34
|
|
52
35
|
parser = LogicParser.new
|
53
|
-
decision = parser.parse ARGV
|
54
|
-
|
55
|
-
if ARGV[0] == 'truth_table'
|
56
|
-
puts decision.truth_table
|
57
|
-
end
|
36
|
+
decision = parser.parse ARGV.join(' ')
|
58
37
|
|
59
|
-
if
|
60
|
-
|
61
|
-
end
|
38
|
+
puts decision.truth_table if options[:truth_table]
|
39
|
+
puts decision.mcdc_pairs if options[:mcdc_pairs]
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 8
|
9
|
+
version: 0.0.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Bryan Ash
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-28 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|