wongi-engine 0.0.2 → 0.0.3

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.
@@ -0,0 +1,54 @@
1
+ require "spec_helper"
2
+
3
+ describe "MAYBE rule" do
4
+
5
+ before :each do
6
+ @engine = Wongi::Engine.create
7
+ end
8
+
9
+ def engine
10
+ @engine
11
+ end
12
+
13
+ it "should pass with existing facts" do
14
+
15
+ engine << rule('test') do
16
+ forall {
17
+ has 1, 2, :X
18
+ maybe :X, 4, :Y
19
+ }
20
+ end
21
+
22
+ prod = engine.productions['test']
23
+
24
+ engine << [1, 2, 3]
25
+ engine << [3, 4, 5]
26
+
27
+ prod.should have(1).tokens
28
+
29
+ prod.tokens.first[:X].should == 3
30
+ prod.tokens.first[:Y].should == 5
31
+
32
+ end
33
+
34
+ it "should pass with missing facts" do
35
+
36
+ engine << rule('test') do
37
+ forall {
38
+ has 1, 2, :X
39
+ maybe :X, 4, :Y
40
+ }
41
+ end
42
+
43
+ prod = engine.productions['test']
44
+
45
+ engine << [1, 2, 3]
46
+
47
+ prod.should have(1).tokens
48
+
49
+ prod.tokens.first[:X].should == 3
50
+ prod.tokens.first[:Y].should be_nil
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe "NCC rule" do
4
+
5
+ before :each do
6
+ @engine = Wongi::Engine.create
7
+ end
8
+
9
+ def engine
10
+ @engine
11
+ end
12
+
13
+ def ncc_rule
14
+ rule('ncc') {
15
+ forall {
16
+ has "base", "is", :Base
17
+ none {
18
+ has :Base, 2, :X
19
+ has :X, 4, 5
20
+ }
21
+ }
22
+ }
23
+ end
24
+
25
+ it 'should pass with a mismatching subchain' do
26
+
27
+ engine << ncc_rule
28
+ production = engine.productions['ncc']
29
+
30
+ engine << ["base", "is", 1]
31
+
32
+ production.should have(1).tokens
33
+
34
+ engine << [1, 2, 3]
35
+
36
+ production.should have(1).tokens
37
+
38
+ engine << [3, 4, 5]
39
+
40
+ production.should have(0).tokens
41
+
42
+ end
43
+
44
+ it 'should remain consistent after retraction' do
45
+
46
+ engine << ncc_rule
47
+ production = engine.productions['ncc']
48
+
49
+ engine << ["base", "is", 1]
50
+ engine << [1, 2, 3]
51
+ engine << [3, 4, 5]
52
+
53
+ production.should have(0).tokens
54
+
55
+ engine.retract [3, 4, 5]
56
+ production.should have(1).tokens
57
+
58
+ engine.retract ["base", "is", 1]
59
+ production.should have(0).tokens
60
+
61
+ end
62
+
63
+
64
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wongi-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-16 00:00:00.000000000 Z
12
+ date: 2012-07-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A rule engine.
15
15
  email:
@@ -30,6 +30,7 @@ files:
30
30
  - lib/wongi-engine.rb
31
31
  - lib/wongi-engine/alpha_memory.rb
32
32
  - lib/wongi-engine/beta.rb
33
+ - lib/wongi-engine/beta/assignment_node.rb
33
34
  - lib/wongi-engine/beta/beta_memory.rb
34
35
  - lib/wongi-engine/beta/beta_node.rb
35
36
  - lib/wongi-engine/beta/filter_node.rb
@@ -57,6 +58,11 @@ files:
57
58
  - lib/wongi-engine/dsl/ncc_production_rule.rb
58
59
  - lib/wongi-engine/dsl/production_rule.rb
59
60
  - lib/wongi-engine/dsl/query.rb
61
+ - lib/wongi-engine/filter.rb
62
+ - lib/wongi-engine/filter/asserting_test.rb
63
+ - lib/wongi-engine/filter/equality_test.rb
64
+ - lib/wongi-engine/filter/filter_test.rb
65
+ - lib/wongi-engine/filter/inequality_test.rb
60
66
  - lib/wongi-engine/graph.rb
61
67
  - lib/wongi-engine/model_context.rb
62
68
  - lib/wongi-engine/network.rb
@@ -70,7 +76,12 @@ files:
70
76
  - lib/wongi-engine/wme_match_data.rb
71
77
  - spec/dataset_spec.rb
72
78
  - spec/dsl_spec.rb
79
+ - spec/filter_specs/assert_test_spec.rb
73
80
  - spec/high_level_spec.rb
81
+ - spec/rule_specs/any_rule_spec.rb
82
+ - spec/rule_specs/assign_spec.rb
83
+ - spec/rule_specs/maybe_rule_spec.rb
84
+ - spec/rule_specs/ncc_spec.rb
74
85
  - spec/ruleset_spec.rb
75
86
  - spec/simple_action_spec.rb
76
87
  - spec/spec_helper.rb
@@ -103,7 +114,12 @@ summary: A rule engine.
103
114
  test_files:
104
115
  - spec/dataset_spec.rb
105
116
  - spec/dsl_spec.rb
117
+ - spec/filter_specs/assert_test_spec.rb
106
118
  - spec/high_level_spec.rb
119
+ - spec/rule_specs/any_rule_spec.rb
120
+ - spec/rule_specs/assign_spec.rb
121
+ - spec/rule_specs/maybe_rule_spec.rb
122
+ - spec/rule_specs/ncc_spec.rb
107
123
  - spec/ruleset_spec.rb
108
124
  - spec/simple_action_spec.rb
109
125
  - spec/spec_helper.rb