01: /**************************************************************************/
02: /* B O S S A */
03: /* A simple imperative object-oriented research language */
04: /* (c) Daniel Bonniot 1999 */
05: /* */
06: /* This program is free software; you can redistribute it and/or modify */
07: /* it under the terms of the GNU General Public License as published by */
08: /* the Free Software Foundation; either version 2 of the License, or */
09: /* (at your option) any later version. */
10: /* */
11: /**************************************************************************/package mlsub.typing;
12:
13: /**
14: * Test class for mlsub.typing
15: *
16: * @author Daniel Bonniot
17: */
18:
19: public class Test {
20: public static void main(String[] args) {
21: System.out.println("Test for mlsub.typing");
22:
23: try {
24: Variance v0 = Variance.make(new int[0]);
25:
26: TypeConstructor a = new TypeConstructor("a", v0, true,
27: false);
28: Monotype ma = new MonotypeConstructor(a, null);
29: Typing.introduce(a);
30: Interface i0 = new Interface(v0);
31: Typing.assertImp(a, i0, true);
32: Interface i1 = new Interface(v0);
33: Typing.assertLeq(i1, i0);
34: //Typing.assertImp(a, i1, true);
35:
36: TypeConstructor t1 = new TypeConstructor(v0);
37: Monotype m1 = new MonotypeConstructor(t1, null);
38: Polytype p1 = new Polytype(
39: new Constraint(new TypeConstructor[] { t1 },
40: new AtomicConstraint[] { new ImplementsCst(
41: t1, i1) }), m1);
42:
43: TypeConstructor t2 = new TypeConstructor(v0);
44: Monotype m2 = new MonotypeConstructor(t2, null);
45: Polytype p2 = new Polytype(new Constraint(
46: new TypeConstructor[] { t2 },
47: new AtomicConstraint[] {
48: new MonotypeLeqCst(m2, ma),
49: new ImplementsCst(t2, i1) }), m2);
50:
51: Typing.dbg = false;
52:
53: Typing.createInitialContext();
54:
55: Typing.leq(p1, p1);
56: } catch (TypingEx e) {
57: System.out.println("Ill typed: " + e);
58: }
59: }
60: }
|