rufus-decision 0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,69 @@
1
+
2
+ #
3
+ # Testing rufus-deciision
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Sun Oct 29 15:41:44 JST 2006
8
+ #
9
+
10
+ require 'test/unit'
11
+
12
+ require 'dmixin'
13
+
14
+
15
+ class DecisionTest < Test::Unit::TestCase
16
+ include DecisionTestMixin
17
+
18
+ #def setup
19
+ #end
20
+
21
+ #def teardown
22
+ #end
23
+
24
+ CSV1 = \
25
+ """
26
+ ,,
27
+ in:fx,in:fy,out:fz
28
+ ,,
29
+ a,${fx},0
30
+ c,d,${fx}
31
+ e,f,${r:3+4}
32
+ g,h,${r:'${fx}' + '${fy}'}
33
+ """
34
+
35
+ def test_1
36
+
37
+ wi = {
38
+ "fx" => "c",
39
+ "fy" => "d"
40
+ }
41
+ do_test(CSV1, wi, {}, { "fz" => "c" }, false)
42
+
43
+ wi = {
44
+ "fx" => "a",
45
+ "fy" => "a"
46
+ }
47
+ do_test(CSV1, wi, {}, { "fz" => "0" }, false)
48
+ end
49
+
50
+ def test_1b
51
+
52
+ h = {
53
+ "fx" => "e",
54
+ "fy" => "f"
55
+ }
56
+ do_test(CSV1, h, { :ruby_eval => true }, { "fz" => "7" }, false)
57
+ end
58
+
59
+ def test_1c
60
+
61
+ h = {
62
+ "fx" => "g",
63
+ "fy" => "h"
64
+ }
65
+ do_test(CSV1, h, { :ruby_eval => true }, { "fz" => "gh" }, false)
66
+ end
67
+
68
+ end
69
+
@@ -0,0 +1,55 @@
1
+
2
+ #
3
+ # Testing rufus-deciision
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Jan 28 13:22:51 JST 2008
8
+ #
9
+
10
+ require 'rufus/decision'
11
+
12
+
13
+ module DecisionTestMixin
14
+
15
+ protected
16
+
17
+ def do_test (table_data, h, options, expected_result, verbose=false)
18
+
19
+ table = Rufus::DecisionTable.new table_data
20
+
21
+ if verbose
22
+ puts
23
+ puts "table :"
24
+ puts table.to_csv
25
+ puts
26
+ puts "before :"
27
+ puts wi
28
+ end
29
+
30
+ h = table.transform! h, options
31
+
32
+ if verbose
33
+ puts
34
+ puts "after :"
35
+ puts h
36
+ end
37
+
38
+ expected_result.each do |k, v|
39
+
40
+ #if wi.attributes[k] != v
41
+ #end
42
+
43
+ value = h[k]
44
+
45
+ value = value.join(';') if value.is_a?(Array)
46
+
47
+ assert \
48
+ value == v,
49
+ "attribute '#{k}' should be set to '#{v}' "+
50
+ "but is set to '#{value}'"
51
+ end
52
+ end
53
+
54
+ end
55
+
@@ -0,0 +1,36 @@
1
+
2
+ #
3
+ # Testing rufus-dollar
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Oct 9 22:19:44 JST 2006
8
+ #
9
+
10
+ require 'test/unit'
11
+ require 'rufus/hashes'
12
+
13
+ #
14
+ # testing the 'dollar notation'
15
+ #
16
+
17
+ class EvalTest < Test::Unit::TestCase
18
+
19
+ #def setup
20
+ #end
21
+
22
+ #def teardown
23
+ #end
24
+
25
+ def test_0
26
+
27
+ eh = Rufus::EvalHashFilter.new({}, 0)
28
+
29
+ eh['a'] = :a
30
+ eh['b'] = "r:5 * 5"
31
+
32
+ assert_equal :a, eh['a']
33
+ assert_equal 25, eh['b']
34
+ assert_equal 72, eh['r:36+36']
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+
2
+ require 'decision_0_test'
3
+ require 'decision_1_test'
4
+ require 'eval_test'
5
+
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rufus-decision
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.9"
5
+ platform: ruby
6
+ authors:
7
+ - John Mettraux
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-01-28 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rufus-dollar
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: rufus-eval
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0"
32
+ version:
33
+ description:
34
+ email: jmettraux@gmail.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - README.txt
41
+ files:
42
+ - lib/rufus
43
+ - lib/rufus/decision.rb
44
+ - lib/rufus/hashes.rb
45
+ - test/decision_0_test.rb
46
+ - test/decision_1_test.rb
47
+ - test/dmixin.rb
48
+ - test/eval_test.rb
49
+ - test/test.rb
50
+ - README.txt
51
+ has_rdoc: true
52
+ homepage: http://rufus.rubyforge.org/rufus-decision
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ requirements:
71
+ - rufus-dollar
72
+ - rufus-eval
73
+ rubyforge_project:
74
+ rubygems_version: 0.9.5
75
+ signing_key:
76
+ specification_version: 2
77
+ summary: CSV based Ruby decision tables
78
+ test_files:
79
+ - test/test.rb