-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.myc
38 lines (37 loc) · 1.48 KB
/
test.myc
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
?- pprint("Running test predicates from file test.myc").
?- pputs("YES => ").
?- YES, pprint(YES).
?- pputs("YES => ").
?- not(NO), pprint(YES).
?- pputs("<0.3| => ").
?- pprint(not(<0.7,1>)).
?- pputs("Hello, world! => ").
?- pprint("Hello, world!").
?- pputs("Hello, world! => ").
?- concat("Hello, ", "world!", X), pprint(X).
?- pputs("YES => ").
?- pprint(not(NO)).
?- pputs("YES => ").
?- pprint(not(not(YES))).
?- pputs("YES => ").
?- pprint(equal(1,1)).
?- pputs("NO => ").
?- pprint(equal(1,2)).
?- pputs("hello => ").
?- set(X, "hello"), pprint(X).
?- pputs("YES => ").
?- add(1, 1, X), pprint(equal(X, 2)).
?- pputs("getBuiltin(getBuiltin/2,X) => ")
?- getBuiltin("getBuiltin/2", X),pprint(X).
?- set(X, "function(world) return YES end"),setBuiltin("testSetBuiltin/0",X),getBuiltin("testSetBuiltin/0",Y),pprint(equal(X,Y)),pputs(X),pputs(" => "),pprint(Y).
?- pprint("Testing parse definition semantics.").
nondet testThing1(X) :- equal(X,X), pprint("PASS").
?- pputs("det testThing1(X) :- equal(X,X), pprint(PASS) => "), testThing1(YES).
nondet testThing2(X) :- pputs(X), pprint(" "), pprint(X), testThing1(X).
?- testThing2(YES).
#?- throw(3, "Hello, error system"), catch(3).
nondet throwIndirect(Z,Y) :- print(Y), throw(Z,Y).
nondet testErrorSystemComplex(X) :- pputs("Attempting to throw embedded error "), throwIndirect(3,X).
?- printWorld().
?- testErrorSystemComplex("Hello, error system complex!"), catch(3).
?- throw(3, "Hello, error system"), true(), catch(3), print("Goodbye, error system").