-
Notifications
You must be signed in to change notification settings - Fork 0
/
t_en.clj
66 lines (56 loc) · 2.49 KB
/
t_en.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
(ns ginfer.t-en
(:require [midje.sweet :refer :all]
[taoensso.timbre :as logger]
[ginfer.attributes.en :refer [export-blueprints import-blueprints]]
[ginfer.attributes.core :refer :all]
[ginfer.steps.core :refer :all]
[ginfer.core :refer :all]))
(background
(around :facts
(let []
(logger/with-level :info ?form))))
(def blueprints-en
'("dog has owner and person has pet"
"dog has-flees?"
"person has-flees? boolean from [[pet has-flees?]]"))
(defn run-scenario [events]
(fact "Dog's owners always get flees"
(let [blueprints (export-blueprints
(import-blueprints blueprints-en))]
(-> blueprints
(infer events :dialect "en")
(get-data "person/joe" :person/has-flees?))) => truthy))
(midje.config/at-print-level
:print-facts
(fact "symmetry of blueprints and natural language"
(export-blueprints
(import-blueprints
blueprints-en)) => '("dog has owner and person has pet"
"dog has-flees?"
"person has pet and dog has owner"
"person has-flees? boolean from [[pet has-flees?]]"))
(run-scenario ["joe's pet is snoopy"
"snoopy dog/has-flees? is true"])
(run-scenario ["snoopy dog/has-flees? is true"
"joe's pet is snoopy"])
(run-scenario ["snoopy's owner is joe"
"snoopy dog/has-flees? is true"])
(run-scenario ["snoopy dog/has-flees? is true"
"snoopy's owner is joe"])
(fact "foo"
(let [blueprints ["company has-many departments and department has company"
"department has-many teams and team has department"
"team has-many employees and employee has team"
"employee allegiance identity from [[team department id]]"]
events ["foo departments add goo"
"goo teams add engineers"
"engineers employees add joe"]
more-events ["foo departments add zoo"
"engineers department is zoo"]
state1 (infer blueprints events :dialect "en")
state2 (infer blueprints more-events
:connectors (get-in state1 [:persistence :connectors])
:dialect "en")]
(get-data state1 "employee/joe" :employee/allegiance) => "department/goo"
(get-data state2 "employee/joe" :employee/allegiance) => "department/zoo"))
)