porolog 0.0.7 → 0.0.8
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/README.md +18 -4
- data/bin/porolog +38 -2
- data/coverage/badge.svg +1 -1
- data/coverage/index.html +52327 -6692
- data/doc/Array.html +113 -33
- data/doc/Object.html +11 -17
- data/doc/Porolog.html +3681 -73
- data/doc/Symbol.html +17 -20
- data/doc/_index.html +181 -13
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +28 -38
- data/doc/index.html +28 -38
- data/doc/method_list.html +871 -167
- data/doc/top-level-namespace.html +2 -2
- data/lib/porolog.rb +1015 -2
- data/lib/porolog/arguments.rb +16 -14
- data/lib/porolog/core_ext.rb +6 -0
- data/lib/porolog/error.rb +6 -0
- data/lib/porolog/goal.rb +205 -68
- data/lib/porolog/instantiation.rb +300 -0
- data/lib/porolog/predicate.rb +33 -16
- data/lib/porolog/rule.rb +129 -2
- data/lib/porolog/scope.rb +3 -3
- data/lib/porolog/tail.rb +52 -0
- data/lib/porolog/value.rb +9 -12
- data/lib/porolog/variable.rb +307 -0
- data/test/porolog/arguments_test.rb +217 -135
- data/test/porolog/core_ext_test.rb +24 -17
- data/test/porolog/goal_test.rb +481 -74
- data/test/porolog/instantiation_test.rb +874 -0
- data/test/porolog/porolog_test.rb +2121 -13
- data/test/porolog/predicate_test.rb +1 -1
- data/test/porolog/rule_test.rb +395 -0
- data/test/porolog/scope_test.rb +0 -2
- data/test/porolog/tail_test.rb +127 -0
- data/test/porolog/value_test.rb +1 -1
- data/test/porolog/variable_test.rb +1625 -0
- data/test/test_helper.rb +78 -5
- metadata +12 -4
data/test/test_helper.rb
CHANGED
@@ -31,6 +31,7 @@ def reset
|
|
31
31
|
Arguments.reset
|
32
32
|
Rule.reset
|
33
33
|
Goal.reset
|
34
|
+
Instantiation.reset
|
34
35
|
end
|
35
36
|
|
36
37
|
def assert_Scope(scope, name, predicates)
|
@@ -59,9 +60,9 @@ def assert_Rule(rule, predicate, arguments, definition)
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def assert_Goal(goal, predicate, arguments)#, definition)
|
62
|
-
assert_instance_of Goal,
|
63
|
-
assert_equal predicate,
|
64
|
-
assert_equal arguments,
|
63
|
+
assert_instance_of Goal, goal
|
64
|
+
assert_equal predicate, goal.arguments.predicate.name
|
65
|
+
assert_equal goal.variablise(arguments), goal.arguments.arguments
|
65
66
|
# TODO: add definition
|
66
67
|
#assert_equal definition, goal.definition
|
67
68
|
end
|
@@ -69,8 +70,80 @@ end
|
|
69
70
|
def assert_Goal_variables(goal, hash, str)
|
70
71
|
assert_instance_of Goal, goal
|
71
72
|
assert_equal hash, goal.variables
|
72
|
-
|
73
|
-
|
73
|
+
assert_equal str, goal.inspect_variables
|
74
|
+
end
|
75
|
+
|
76
|
+
def assert_Value(value, value_value, goal)
|
77
|
+
assert_instance_of Value, value
|
78
|
+
assert_equal value_value, value.value
|
79
|
+
assert_equal goal, value.goal
|
80
|
+
end
|
81
|
+
|
82
|
+
def assert_Variable(variable, name, goal, instantiations, values)
|
83
|
+
assert_instance_of Variable, variable
|
84
|
+
assert_equal name, variable.name
|
85
|
+
assert_equal goal, variable.goal
|
86
|
+
assert_equal instantiations, variable.instantiations
|
87
|
+
assert_equal values, variable.values
|
88
|
+
end
|
89
|
+
|
90
|
+
def assert_Instantiation(instantiation, variable1, variable2, index1, index2)
|
91
|
+
assert_instance_of Instantiation, instantiation
|
92
|
+
assert_includes [Variable,Value], variable1.class
|
93
|
+
assert_includes [Variable,Value], variable2.class
|
94
|
+
assert_equal variable1, instantiation.variable1
|
95
|
+
assert_equal variable2, instantiation.variable2
|
96
|
+
if index1
|
97
|
+
assert_equal index1, instantiation.index1
|
98
|
+
else
|
99
|
+
assert_nil instantiation.index1
|
100
|
+
end
|
101
|
+
if index2
|
102
|
+
assert_equal index2, instantiation.index2
|
103
|
+
else
|
104
|
+
assert_nil instantiation.index2
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def assert_Tail(tail, inspect)
|
109
|
+
assert_instance_of Tail, tail
|
110
|
+
assert_equal inspect, tail.inspect
|
111
|
+
end
|
112
|
+
|
113
|
+
def assert_Array_with_Tail(array, head, inspect)
|
114
|
+
assert_instance_of Array, array
|
115
|
+
assert_equal head.size + 1, array.size
|
116
|
+
assert_equal head, array[0...head.size]
|
117
|
+
assert_Tail array.last, inspect
|
118
|
+
end
|
119
|
+
|
120
|
+
def expect_unify_arrays_with_calls(no_tails, some_tails, all_tails)
|
121
|
+
expects(:unify_arrays_with_no_tails ).times(no_tails)
|
122
|
+
expects(:unify_arrays_with_some_tails).times(some_tails)
|
123
|
+
expects(:unify_arrays_with_all_tails ).times(all_tails)
|
124
|
+
end
|
125
|
+
|
126
|
+
def assert_Unify_arrays(arrays, goals, merged, unifications = [])
|
127
|
+
result_merged, result_unifications = unify_arrays(*arrays, *goals)
|
128
|
+
|
129
|
+
unifications = unifications.map{|v1,v2,g1,g2|
|
130
|
+
assert_instance_of Goal, g1
|
131
|
+
assert_instance_of Goal, g2
|
132
|
+
[g1.variablise(v1), g2.variablise(v2), g1, g2]
|
133
|
+
}
|
134
|
+
|
135
|
+
assert_equal merged, result_merged
|
136
|
+
assert_equal unifications, result_unifications
|
137
|
+
end
|
138
|
+
|
139
|
+
def refute_Unify_arrays(arrays, goals, log = [])
|
140
|
+
result = unify_arrays(*arrays, *goals)
|
141
|
+
|
142
|
+
assert_nil result
|
143
|
+
|
144
|
+
goals.each do |goal|
|
145
|
+
assert_equal log, goal.log
|
146
|
+
end
|
74
147
|
end
|
75
148
|
|
76
149
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: porolog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis Esteban
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Implements a Prolog inference engine using Plain Old Ruby Objects (work
|
14
14
|
in progress)
|
@@ -40,18 +40,24 @@ files:
|
|
40
40
|
- lib/porolog/core_ext.rb
|
41
41
|
- lib/porolog/error.rb
|
42
42
|
- lib/porolog/goal.rb
|
43
|
+
- lib/porolog/instantiation.rb
|
43
44
|
- lib/porolog/predicate.rb
|
44
45
|
- lib/porolog/rule.rb
|
45
46
|
- lib/porolog/scope.rb
|
47
|
+
- lib/porolog/tail.rb
|
46
48
|
- lib/porolog/value.rb
|
49
|
+
- lib/porolog/variable.rb
|
47
50
|
- test/porolog/arguments_test.rb
|
48
51
|
- test/porolog/core_ext_test.rb
|
49
52
|
- test/porolog/goal_test.rb
|
53
|
+
- test/porolog/instantiation_test.rb
|
50
54
|
- test/porolog/porolog_test.rb
|
51
55
|
- test/porolog/predicate_test.rb
|
52
56
|
- test/porolog/rule_test.rb
|
53
57
|
- test/porolog/scope_test.rb
|
58
|
+
- test/porolog/tail_test.rb
|
54
59
|
- test/porolog/value_test.rb
|
60
|
+
- test/porolog/variable_test.rb
|
55
61
|
- test/test_helper.rb
|
56
62
|
homepage: https://github.com/wizardofosmium/porolog
|
57
63
|
licenses:
|
@@ -72,13 +78,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
78
|
- !ruby/object:Gem::Version
|
73
79
|
version: '0'
|
74
80
|
requirements: []
|
75
|
-
|
76
|
-
rubygems_version: 2.7.6
|
81
|
+
rubygems_version: 3.0.3
|
77
82
|
signing_key:
|
78
83
|
specification_version: 4
|
79
84
|
summary: Prolog using Plain Old Ruby Objects (work in progress)
|
80
85
|
test_files:
|
81
86
|
- test/test_helper.rb
|
87
|
+
- test/porolog/instantiation_test.rb
|
88
|
+
- test/porolog/variable_test.rb
|
89
|
+
- test/porolog/tail_test.rb
|
82
90
|
- test/porolog/porolog_test.rb
|
83
91
|
- test/porolog/goal_test.rb
|
84
92
|
- test/porolog/core_ext_test.rb
|