-
Notifications
You must be signed in to change notification settings - Fork 0
/
z3-test.js
51 lines (44 loc) · 1.15 KB
/
z3-test.js
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
import * as z3 from './z3.js';
function equals(a1, a2) {
if (!Array.isArray(a1) || !Array.isArray(a2)) {
throw new Error("Arguments to function equals(a1, a2) must be arrays.");
}
if (a1.length !== a2.length) {
return false;
}
for (var i=0; i<a1.length; i++) {
if (Array.isArray(a1[i]) && Array.isArray(a2[i])) {
if (equals(a1[i], a2[i])) {
continue;
} else {
return false;
}
} else {
if (a1[i] !== a2[i]) {
return false;
}
}
}
return true;
}
var self = {};
describe('z3', function() {
beforeEach(function() {
self = {
assert: function(cond, msg) {
if (!cond) {
throw new Error(msg || "Assertion error");
}
}
};
});
it("Disjunction", function () {
var solver = new z3.EmZ3(true),
v = new z3.Variable('v1', 0, solver),
c = v.cnGeq(12);
self.assert(v.value == 0);
c.enable();
solver.solve();
self.assert(v.value == 12);
});
});