-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlloy.als
More file actions
92 lines (73 loc) · 1.89 KB
/
Alloy.als
File metadata and controls
92 lines (73 loc) · 1.89 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
sig Login {
username: String,
password: String,
email: String,
phoneNumber: String,
discPage: DiscoveryPage
}
sig DiscoveryPage {
itemName: String,
discovery: Discovery,
sessionStatus: String
}
sig Discovery {
listProduct: some Product
}
sig Product {
itemID: String,
price: Int
}
sig Batu extends Product {
satuanM3: Int
}
sig Besi extends Product{
panjang: Int
}
sig Semen extends Product {
perSak: Int
}
pred checkSession[l: Login] {
// Implementation of the checkSession method
l.discPage.sessionStatus = "active"
}
pred search[dp: DiscoveryPage, itemNameToSearch: String] {
// Implementation of the search method
some p: Product | p in dp.discovery.listProduct and dp.itemName = itemNameToSearch
}
pred productInfo[p: Product] {
// Implementation of the productInfo method
p in Discovery.listProduct
}
pred getPriceBatu[b: Batu, p: Product] {
// Implementation of the getPrice method for Batu
p in Discovery.listProduct =>
let totalPrice = mul[b.satuanM3, p.price] |
totalPrice > 0
}
pred getPriceBesi[b: Besi, p: Product] {
// Implementation of the getPrice method for Besi
p in Discovery.listProduct =>
let totalPrice = mul[b.panjang,p.price] |
totalPrice > 0
}
pred getPriceSemen[s: Semen, p: Product] {
// Implementation of the getPrice method for Semen
p in Discovery.listProduct =>
let totalPrice = mul[s.perSak,p.price] |
totalPrice > 0
}
pred show {
all l: Login, dp: DiscoveryPage |
checkSession[l] and search[dp, dp.itemName]
}
fact {
one login: Login, dp: DiscoveryPage |
login.discPage = dp and
dp.sessionStatus = "active"
}
assert AssertionCheckSessionActive {
all l: Login, dp: DiscoveryPage |
checkSession[l] and search[dp, dp.itemName]
}
run show for 5 but 4 Product, 3 Batu, 3 Besi, 3 Semen
check AssertionCheckSessionActive