rubylog 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/Gemfile +2 -0
  2. data/Gemfile.lock +10 -0
  3. data/README.rdoc +1 -1
  4. data/RELEASE_NOTES.rdoc +7 -4
  5. data/VERSION +1 -1
  6. data/{examples → benchmark}/benchmark.rb +1 -0
  7. data/{examples → benchmark}/benchmark/compiled_not_indexed.rb +0 -0
  8. data/{examples → benchmark}/benchmark/compiled_sequence_indexed.rb +0 -0
  9. data/{examples → benchmark}/benchmark/indexed_procedure.rb +0 -0
  10. data/{examples → benchmark}/benchmark/prolog.rb +0 -0
  11. data/benchmark/benchmark/pure.rb +28 -0
  12. data/bin/rubylog +14 -0
  13. data/examples/a_plus_b.rb +2 -2
  14. data/examples/dcg.rb +22 -26
  15. data/examples/dcg2.rb +25 -30
  16. data/examples/divisors.rb +1 -3
  17. data/examples/factorial.rb +8 -15
  18. data/examples/file_search.rb +14 -13
  19. data/examples/hanoi.rb +1 -3
  20. data/examples/hu/csaladfa.rb +0 -4
  21. data/examples/n_queens.rb +17 -22
  22. data/examples/palindrome_detection.rb +1 -2
  23. data/examples/parsing.rb +19 -23
  24. data/examples/permutation.rb +1 -3
  25. data/examples/primality_by_division.rb +2 -2
  26. data/examples/sieve_of_eratosthenes.rb +2 -2
  27. data/examples/string_interpolation.rb +0 -3
  28. data/examples/tracing.rb +0 -4
  29. data/lib/rubylog/builtins/assumption.rb +2 -1
  30. data/lib/rubylog/builtins/file_system.rb +1 -1
  31. data/lib/rubylog/default_context.rb +3 -5
  32. data/lib/rubylog/mixins/kernel.rb +9 -1
  33. data/lib/rubylog/rubylog_files.rb +7 -0
  34. data/rubylog.gemspec +17 -22
  35. data/spec/inriasuite_spec.rb +851 -847
  36. data/spec/integration/dsl_spec.rb +32 -29
  37. data/spec/rspec/rubylog_spec.rb +46 -52
  38. data/spec/rubylog/assertable_spec.rb +92 -90
  39. data/spec/rubylog/builtins/arithmetics_spec.rb +92 -90
  40. data/spec/rubylog/builtins/assumption_spec.rb +59 -57
  41. data/spec/rubylog/builtins/ensure_spec.rb +6 -4
  42. data/spec/rubylog/builtins/file_system_spec.rb +41 -39
  43. data/spec/rubylog/builtins/logic_spec.rb +308 -306
  44. data/spec/rubylog/builtins/reflection_spec.rb +31 -29
  45. data/spec/rubylog/builtins/term_spec.rb +62 -60
  46. data/spec/rubylog/context_modules/demonstration_spec.rb +108 -106
  47. data/spec/rubylog/context_modules/predicates_spec.rb +29 -27
  48. data/spec/rubylog/context_modules/thats_spec.rb +77 -75
  49. data/spec/rubylog/dsl/array_splat_spec.rb +11 -9
  50. data/spec/rubylog/dsl/indicators_spec.rb +23 -21
  51. data/spec/rubylog/dsl/primitives_spec.rb +30 -28
  52. data/spec/rubylog/errors_spec.rb +13 -11
  53. data/spec/rubylog/interfaces/term_spec.rb +78 -76
  54. data/spec/rubylog/mixins/array_spec.rb +60 -58
  55. data/spec/rubylog/mixins/composite_term_spec.rb +55 -53
  56. data/spec/rubylog/mixins/proc_spec.rb +48 -46
  57. data/spec/rubylog/mixins/string_spec.rb +45 -43
  58. data/spec/rubylog/mixins/symbol_spec.rb +7 -5
  59. data/spec/rubylog/procedure_spec.rb +8 -6
  60. data/spec/rubylog/rule_spec.rb +10 -8
  61. data/spec/rubylog/structure_spec.rb +73 -71
  62. data/spec/rubylog/term_spec.rb +5 -3
  63. data/spec/rubylog/tracing_spec.rb +35 -33
  64. data/spec/rubylog/variable_spec.rb +249 -247
  65. data/spec/spec_helper.rb +4 -0
  66. metadata +54 -43
  67. data/examples/benchmark/pure.rb +0 -26
  68. data/examples/checkmate.rb +0 -88
  69. data/examples/combination.rb +0 -17
  70. data/examples/directory_structure_logic.rb +0 -17
  71. data/examples/dirlist.rb +0 -4
  72. data/examples/enumerators.rb +0 -30
  73. data/examples/hello.rb +0 -17
  74. data/examples/mice.rb +0 -92
  75. data/examples/mice2.rb +0 -37
  76. data/examples/object_oriented.rb +0 -14
  77. data/examples/prefix.rb +0 -13
  78. data/examples/primitives.rb +0 -26
  79. data/examples/sudoku.rb +0 -17
  80. data/spec/integration/theory_as_module_spec.rb +0 -20
  81. data/spec/integration/theory_as_module_with_include_spec.rb +0 -14
@@ -1,38 +1,41 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "Rubylog dsl", :rubylog=>true do
4
-
5
- describe "prefix functors" do
6
- before do
7
- predicate_for singleton_class, ".we_have()"
8
- we_have! :weapons
9
- we_have! :sunglasses
10
- we_have! :rustling_leather_coats
11
- end
3
+ module RubylogSpec
12
4
 
13
- it "works" do
14
- check we_have :sunglasses
15
- end
16
-
17
- it "works with qmarks" do
18
- check { we_have? :rustling_leather_coats }
5
+ describe "Rubylog dsl", :rubylog=>true do
6
+
7
+ describe "prefix functors" do
8
+ before do
9
+ predicate_for singleton_class, ".we_have()"
10
+ we_have! :weapons
11
+ we_have! :sunglasses
12
+ we_have! :rustling_leather_coats
13
+ end
14
+
15
+ it "works" do
16
+ check we_have :sunglasses
17
+ end
18
+
19
+ it "works with qmarks" do
20
+ check { we_have? :rustling_leather_coats }
21
+ end
19
22
  end
20
- end
21
23
 
22
24
 
23
- describe "built-in prefix functors" do
24
- check all X.is(4).and(Y.is(X)), Y.is(4)
25
- check any X.is(4)
26
- check one(X.in([1,2,3])) { X % 2 == 0 }
27
- check none X.in([1,2,3]), X.is(5)
28
- check { all?(X.is(4)) { X < 5 } }
29
- end
25
+ describe "built-in prefix functors" do
26
+ check all X.is(4).and(Y.is(X)), Y.is(4)
27
+ check any X.is(4)
28
+ check one(X.in([1,2,3])) { X % 2 == 0 }
29
+ check none X.in([1,2,3]), X.is(5)
30
+ check { all?(X.is(4)) { X < 5 } }
31
+ end
30
32
 
31
- describe "variables" do
32
- check A.is(ANY).and{ A == Rubylog::Variable.new(:ANY) }
33
- check A.is(4) .and{ A == 4 }
34
- check B.is(A) .and{ A == Rubylog::Variable.new(:A) and B == Rubylog::Variable.new(:A) }
35
- check B.is(ANY).and{ A == Rubylog::Variable.new(:A) }
36
- end
33
+ describe "variables" do
34
+ check A.is(ANY).and{ A == Rubylog::Variable.new(:ANY) }
35
+ check A.is(4) .and{ A == 4 }
36
+ check B.is(A) .and{ A == Rubylog::Variable.new(:A) and B == Rubylog::Variable.new(:A) }
37
+ check B.is(ANY).and{ A == Rubylog::Variable.new(:A) }
38
+ end
37
39
 
40
+ end
38
41
  end
@@ -1,75 +1,69 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "Rubylog", :rubylog => true do
3
+ module RubylogSpec
4
+ describe "Rubylog", :rubylog => true do
4
5
 
5
- predicate_for Integer, ".even"
6
+ predicate_for Integer, ".even"
6
7
 
7
- N.even.if { N%2 == 0 }
8
+ N.even.if { N%2 == 0 }
8
9
 
9
- it "checks for true statements" do
10
- check :true
11
- end
10
+ it "checks for true statements" do
11
+ check :true
12
+ end
12
13
 
13
- it "raises an exception for false statements" do
14
- proc{check :fail}.should raise_exception(Rubylog::CheckFailed)
14
+ it "raises an exception for false statements" do
15
+ proc{check :fail}.should raise_exception(Rubylog::CheckFailed)
15
16
 
16
- self.default_subject = Integer
17
- proc{check 4.is 5}.should raise_exception(Rubylog::CheckFailed)
18
- end
17
+ self.default_subject = Integer
18
+ proc{check 4.is 5}.should raise_exception(Rubylog::CheckFailed)
19
+ end
19
20
 
20
- it "can use variables" do
21
- check A.is 3
22
- end
21
+ it "can use predicates" do
22
+ check((A.in [1,2]).and(B.in([2,3])).and(A.is 1).and(B.is 3))
23
+ end
23
24
 
24
- it "can use predicates" do
25
- check((A.in [1,2]).and(B.in([2,3])).and(A.is 1).and(B.is 3))
26
- end
25
+ it "can assert predicates" do
26
+ predicate_for Integer, ".divides()"
27
+ (A.divides B).if {B%A == 0}
28
+ check(4.divides 12)
29
+ check((4.divides 30).false)
30
+ end
27
31
 
28
- it "can assert predicates" do
29
- predicate_for Integer, ".divides()"
30
- (A.divides B).if {B%A == 0}
31
- check(4.divides 12)
32
- check((4.divides 30).false)
33
- end
32
+ it "can use predicates defined outside" do
33
+ check 1.even.false
34
+ check 2.even
35
+ end
34
36
 
35
- it "can use predicates defined outside" do
36
- check 1.even.false
37
- check 2.even
38
- end
37
+ describe "nested check" do
38
+ it "works" do
39
+ check 9.even.false
40
+ end
41
+ end
39
42
 
40
- describe "nested check" do
41
- it "works" do
42
- check 9.even.false
43
+ # inline check
44
+ check 0.even
45
+
46
+ describe "nested inline check" do
47
+ check 3.even.false
48
+ check 4.even
43
49
  end
44
- end
45
50
 
46
- # inline check
47
- check 0.even
48
-
49
- describe "nested inline check" do
50
- check 3.even.false
51
- check 4.even
52
51
  end
53
52
 
54
- end
53
+ describe "Rubylog" do
54
+ describe "when not included" do
55
55
 
56
- describe "Rubylog" do
57
- describe "when not included" do
56
+ it "does not add methods" do
57
+ proc{check :true}.should raise_exception NameError
58
+ proc{trace}.should raise_exception NameError
59
+ end
58
60
 
59
- it "does not add methods" do
60
- proc{check :true}.should raise_exception NameError
61
- proc{trace}.should raise_exception NameError
62
61
  end
63
-
64
- it "does not add constants" do
65
- proc{A}.should raise_exception NameError
66
- end
67
-
68
62
  end
69
- end
70
63
 
64
+ end
71
65
 
72
66
 
73
- #require "rspec/core/formatters/progress_formatter"
74
- #require "rspec/core/formatters/documentation_formatter"
75
- #EG.run RSpec::Core::Reporter.new RSpec::Core::Formatters::DocumentationFormatter.new(STDOUT)
67
+ #require "rspec/core/formatters/progress_formatter"
68
+ #require "rspec/core/formatters/documentation_formatter"
69
+ #EG.run RSpec::Core::Reporter.new RSpec::Core::Formatters::DocumentationFormatter.new(STDOUT)
@@ -1,111 +1,113 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "rules", :rubylog=>true do
4
- before do
5
- predicate_for Symbol, ".likes(Drink) .is_happy .has()"
6
- predicate_for_context ".we_have()"
7
- end
8
-
9
- describe "with prolog body" do
10
- it "cannot be asserted in a builtin's desc" do
11
- lambda {
12
- :john.likes(:beer).and! :jane.likes(:milk)
13
- }.should raise_error
3
+ module RubylogSpec
4
+ describe "rules", :rubylog=>true do
5
+ before do
6
+ predicate_for Symbol, ".likes(Drink) .is_happy .has()"
7
+ predicate_for_context ".we_have()"
14
8
  end
15
9
 
16
- it "can be asserted with if" do
17
- :john.is_happy.if we_have(:beer)
18
- :john.is_happy?.should be_false
19
- we_have!(:beer)
20
- :john.is_happy?.should be_true
21
- end
10
+ describe "with prolog body" do
11
+ it "cannot be asserted in a builtin's desc" do
12
+ lambda {
13
+ :john.likes(:beer).and! :jane.likes(:milk)
14
+ }.should raise_error
15
+ end
22
16
 
23
- it "can be asserted with unless" do
24
- :john.is_happy.unless we_have(:problem)
25
- :john.is_happy?.should be_true
26
- we_have!(:problem)
27
- :john.is_happy?.should be_false
28
- end
17
+ it "can be asserted with if" do
18
+ :john.is_happy.if we_have(:beer)
19
+ :john.is_happy?.should be_false
20
+ we_have!(:beer)
21
+ :john.is_happy?.should be_true
22
+ end
29
23
 
30
- it "can do simple general implications" do
31
- X.is_happy.if X.likes(Y).and X.has(Y)
32
- :john.likes! :milk
33
- :john.is_happy?.should be_false
34
- :john.has! :beer
35
- :john.is_happy?.should be_false
36
- :john.likes! :beer
37
- :john.is_happy?.should be_true
38
- end
24
+ it "can be asserted with unless" do
25
+ :john.is_happy.unless we_have(:problem)
26
+ :john.is_happy?.should be_true
27
+ we_have!(:problem)
28
+ :john.is_happy?.should be_false
29
+ end
39
30
 
40
- it "can yield implied solutions" do
41
- predicate_for Symbol, ".brother() .father() .uncle()"
42
- X.brother(Y).if X.father(Z).and Y.father(Z).and {X != Y}
43
- X.uncle(Y).if X.father(Z).and Z.brother(Y)
31
+ it "can do simple general implications" do
32
+ X.is_happy.if X.likes(Y).and X.has(Y)
33
+ :john.likes! :milk
34
+ :john.is_happy?.should be_false
35
+ :john.has! :beer
36
+ :john.is_happy?.should be_false
37
+ :john.likes! :beer
38
+ :john.is_happy?.should be_true
39
+ end
44
40
 
45
- :john.father! :dad
46
- :jack.father! :dad
47
- :dad.father! :grandpa
48
- :jim.father! :grandpa
41
+ it "can yield implied solutions" do
42
+ predicate_for Symbol, ".brother() .father() .uncle()"
43
+ X.brother(Y).if X.father(Z).and Y.father(Z).and {X != Y}
44
+ X.uncle(Y).if X.father(Z).and Z.brother(Y)
49
45
 
50
- (:john.brother X).map{X}.should == [:jack]
51
- (:john.father X).map{X}.should == [:dad]
52
- (X.father :dad).map{X}.should == [:john, :jack]
53
- (ANY.father X).map{X}.should == [:dad, :dad, :grandpa, :grandpa]
54
- (:john.uncle X).map{X}.should == [:jim]
55
- end
56
- end
46
+ :john.father! :dad
47
+ :jack.father! :dad
48
+ :dad.father! :grandpa
49
+ :jim.father! :grandpa
57
50
 
58
- describe "with ruby body" do
59
- it "can be asserted (true)" do
60
- :john.is_happy.if proc{ true }
61
- :john.is_happy?.should be_true
51
+ (:john.brother X).map{X}.should == [:jack]
52
+ (:john.father X).map{X}.should == [:dad]
53
+ (X.father :dad).map{X}.should == [:john, :jack]
54
+ (ANY.father X).map{X}.should == [:dad, :dad, :grandpa, :grandpa]
55
+ (:john.uncle X).map{X}.should == [:jim]
56
+ end
62
57
  end
63
58
 
64
- it "can be asserted (false)" do
65
- :john.is_happy.if proc{ false }
66
- :john.is_happy?.should be_false
67
- end
59
+ describe "with ruby body" do
60
+ it "can be asserted (true)" do
61
+ :john.is_happy.if proc{ true }
62
+ :john.is_happy?.should be_true
63
+ end
68
64
 
69
- it "can be asserted implicitly (true)" do
70
- :john.is_happy.if { true }
71
- :john.is_happy?.should be_true
72
- end
65
+ it "can be asserted (false)" do
66
+ :john.is_happy.if proc{ false }
67
+ :john.is_happy?.should be_false
68
+ end
73
69
 
74
- it "can be asserted implicitly (false)" do
75
- :john.is_happy.if { false }
76
- :john.is_happy?.should be_false
77
- end
70
+ it "can be asserted implicitly (true)" do
71
+ :john.is_happy.if { true }
72
+ :john.is_happy?.should be_true
73
+ end
78
74
 
79
- it "run the body during every query" do
80
- count = 0
81
- :john.is_happy.if proc{ count += 1 }
82
- count.should == 0
83
- :john.is_happy?
84
- count.should == 1
85
- :john.is_happy?
86
- count.should == 2
87
- end
75
+ it "can be asserted implicitly (false)" do
76
+ :john.is_happy.if { false }
77
+ :john.is_happy?.should be_false
78
+ end
79
+
80
+ it "run the body during every query" do
81
+ count = 0
82
+ :john.is_happy.if proc{ count += 1 }
83
+ count.should == 0
84
+ :john.is_happy?
85
+ count.should == 1
86
+ :john.is_happy?
87
+ count.should == 2
88
+ end
88
89
 
89
- it "can take arguments" do
90
- predicate_for Integer, ".divides()"
91
- (A.divides B).if proc{B % A == 0}
92
- (4.divides? 16).should be_true
93
- (4.divides? 17).should be_false
94
- (4.divides? 18).should be_false
95
- (3.divides? 3).should be_true
96
- (3.divides? 4).should be_false
97
- (3.divides? 5).should be_false
98
- (3.divides? 6).should be_true
90
+ it "can take arguments" do
91
+ predicate_for Integer, ".divides()"
92
+ (A.divides B).if proc{B % A == 0}
93
+ (4.divides? 16).should be_true
94
+ (4.divides? 17).should be_false
95
+ (4.divides? 18).should be_false
96
+ (3.divides? 3).should be_true
97
+ (3.divides? 4).should be_false
98
+ (3.divides? 5).should be_false
99
+ (3.divides? 6).should be_true
100
+ end
99
101
  end
100
- end
101
102
 
102
- describe "#if!" do
103
- it "can be used to cut off branches" do
104
- predicate_for Integer, ".divides()"
105
- 1.divides(X).if! :true
106
- (A.divides B).if proc{B % A == 0}
107
- 1.divides(4).map{}.should == [nil]
108
- 2.divides(4).map{}.should == [nil]
103
+ describe "#if!" do
104
+ it "can be used to cut off branches" do
105
+ predicate_for Integer, ".divides()"
106
+ 1.divides(X).if! :true
107
+ (A.divides B).if proc{B % A == 0}
108
+ 1.divides(4).map{}.should == [nil]
109
+ 2.divides(4).map{}.should == [nil]
110
+ end
109
111
  end
110
112
  end
111
113
  end
@@ -1,94 +1,96 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "Arithmetics builtins", :rubylog=>true do
4
- check 5.sum_of 2, 3
5
-
6
- check((5.sum_of 2, 6).false)
7
-
8
- check { 5.sum_of(3, A).map{A}.eql? [2] }
9
- check { 5.sum_of(A, 2).map{A}.eql? [3] }
10
- check { A.sum_of(3, 4).map{A}.eql? [7] }
11
-
12
- check A.is(5).and B.is(3).and C.is(2).and A.sum_of(C, B)
13
-
14
- it "works with functions" do
15
- check A.is(5).and 5.sum_of(proc{2}, proc{A-2})
16
- check A.is(5).and 5.sum_of(proc{3}, proc{A-2}).false
17
- end
18
-
19
- it "checks types" do
20
- check 4.sum_of(2,2.0).false
21
- check 4.0.sum_of(2.0,2.0)
22
- end
23
-
24
- it "can add strings" do
25
- A.sum_of(B,C).predicate.add_functor_to String
26
- check "hello".sum_of("he", "llo")
27
- end
28
-
29
- it "can add arrays" do
30
- A.sum_of(B,C).predicate.add_functor_to Array
31
- check [1,2,3].sum_of([1,2], [3])
32
- end
33
-
34
- it "can subtract arrays" do
35
- A.sum_of(B,C).predicate.add_functor_to Array
36
- [1,2,3].sum_of(X, [3]).map{X}.should be_eql [[1,2]]
37
- end
38
-
39
- it "can multiply integers" do
40
- A.product_of(3,2).map{A}.should be_eql [6]
41
- end
42
-
43
- it "can divide integers" do
44
- 6.product_of(A,2).map{A}.should be_eql [3]
45
- end
46
-
47
- it "can divide integers" do
48
- 6.product_of(3,A).map{A}.should be_eql [2]
49
- end
50
-
51
- it "can divide floats" do
52
- 6.0.product_of(A,2.0).map{A}.should be_eql [3.0]
53
- end
54
-
55
- it "can divide floats" do
56
- 6.0.product_of(3.0,A).map{A}.should be_eql [2.0]
57
- end
58
-
59
- it "checks non-divisibility of integers" do
60
- 6.product_of(5,A).map{A}.should be_eql []
61
- end
62
-
63
- it "checks non-divisibility of integers" do
64
- 6.product_of(A,4).map{A}.should be_eql []
65
- end
66
-
67
- it "casts types" do
68
- 6.0.product_of(A,2).map{A}.should be_eql [3.0]
69
- end
70
-
71
- it "casts types" do
72
- 6.0.product_of(3,A).map{A}.should be_eql [2.0]
73
- end
74
-
75
- it "casts types" do
76
- A.product_of(3,2.0).map{A}.should be_eql [6.0]
77
- end
78
-
79
- it "checks instatiation" do
80
- expect { 8.product_of(B,C).map{[B,C]} }.to raise_error Rubylog::InstantiationError
81
- end
82
-
83
- it "checks instatiation" do
84
- expect { 8.sum_of(B,C).map{[B,C]} }.to raise_error Rubylog::InstantiationError
85
- end
86
-
87
- it "checks instatiation" do
88
- expect { A.sum_of(B,2).map{[B,C]} }.to raise_error Rubylog::InstantiationError
89
- end
90
-
91
- it "checks instatiation" do
92
- expect { A.product_of(B,2).map{[B,C]} }.to raise_error Rubylog::InstantiationError
3
+ module RubylogSpec
4
+ describe "Arithmetics builtins", :rubylog=>true do
5
+ check 5.sum_of 2, 3
6
+
7
+ check((5.sum_of 2, 6).false)
8
+
9
+ check { 5.sum_of(3, A).map{A}.eql? [2] }
10
+ check { 5.sum_of(A, 2).map{A}.eql? [3] }
11
+ check { A.sum_of(3, 4).map{A}.eql? [7] }
12
+
13
+ check A.is(5).and B.is(3).and C.is(2).and A.sum_of(C, B)
14
+
15
+ it "works with functions" do
16
+ check A.is(5).and 5.sum_of(proc{2}, proc{A-2})
17
+ check A.is(5).and 5.sum_of(proc{3}, proc{A-2}).false
18
+ end
19
+
20
+ it "checks types" do
21
+ check 4.sum_of(2,2.0).false
22
+ check 4.0.sum_of(2.0,2.0)
23
+ end
24
+
25
+ it "can add strings" do
26
+ A.sum_of(B,C).predicate.add_functor_to String
27
+ check "hello".sum_of("he", "llo")
28
+ end
29
+
30
+ it "can add arrays" do
31
+ A.sum_of(B,C).predicate.add_functor_to Array
32
+ check [1,2,3].sum_of([1,2], [3])
33
+ end
34
+
35
+ it "can subtract arrays" do
36
+ A.sum_of(B,C).predicate.add_functor_to Array
37
+ [1,2,3].sum_of(X, [3]).map{X}.should be_eql [[1,2]]
38
+ end
39
+
40
+ it "can multiply integers" do
41
+ A.product_of(3,2).map{A}.should be_eql [6]
42
+ end
43
+
44
+ it "can divide integers" do
45
+ 6.product_of(A,2).map{A}.should be_eql [3]
46
+ end
47
+
48
+ it "can divide integers" do
49
+ 6.product_of(3,A).map{A}.should be_eql [2]
50
+ end
51
+
52
+ it "can divide floats" do
53
+ 6.0.product_of(A,2.0).map{A}.should be_eql [3.0]
54
+ end
55
+
56
+ it "can divide floats" do
57
+ 6.0.product_of(3.0,A).map{A}.should be_eql [2.0]
58
+ end
59
+
60
+ it "checks non-divisibility of integers" do
61
+ 6.product_of(5,A).map{A}.should be_eql []
62
+ end
63
+
64
+ it "checks non-divisibility of integers" do
65
+ 6.product_of(A,4).map{A}.should be_eql []
66
+ end
67
+
68
+ it "casts types" do
69
+ 6.0.product_of(A,2).map{A}.should be_eql [3.0]
70
+ end
71
+
72
+ it "casts types" do
73
+ 6.0.product_of(3,A).map{A}.should be_eql [2.0]
74
+ end
75
+
76
+ it "casts types" do
77
+ A.product_of(3,2.0).map{A}.should be_eql [6.0]
78
+ end
79
+
80
+ it "checks instatiation" do
81
+ expect { 8.product_of(B,C).map{[B,C]} }.to raise_error Rubylog::InstantiationError
82
+ end
83
+
84
+ it "checks instatiation" do
85
+ expect { 8.sum_of(B,C).map{[B,C]} }.to raise_error Rubylog::InstantiationError
86
+ end
87
+
88
+ it "checks instatiation" do
89
+ expect { A.sum_of(B,2).map{[B,C]} }.to raise_error Rubylog::InstantiationError
90
+ end
91
+
92
+ it "checks instatiation" do
93
+ expect { A.product_of(B,2).map{[B,C]} }.to raise_error Rubylog::InstantiationError
94
+ end
93
95
  end
94
96
  end