From f4d0dbf95dc000fbe5fb283378a19f226a5d3382 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Tue, 12 Apr 2016 12:14:31 +0200 Subject: [PATCH] =?UTF-8?q?Unify=20Test=20anf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/unify/UnifyTest.java | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/unify/UnifyTest.java b/test/unify/UnifyTest.java index 29d73c9d..40382a61 100644 --- a/test/unify/UnifyTest.java +++ b/test/unify/UnifyTest.java @@ -614,6 +614,55 @@ public class UnifyTest extends Unify { System.out.println(actual); } + @Test + public void unifyTestVoid() { + /* + * Constraints Set mit "void" Typen + */ + TypeFactory tf = new TypeFactory(); + FiniteClosureBuilder fcb = new FiniteClosureBuilder(); + + UnifyType tphT1 = tf.getPlaceholderType("T1"); + UnifyType tphT2 = tf.getPlaceholderType("T2"); + UnifyType tphT3 = tf.getPlaceholderType("T3"); + UnifyType tphT4 = tf.getPlaceholderType("T4"); + UnifyType tphT5 = tf.getPlaceholderType("T4"); + + UnifyType integer = tf.getSimpleType("java.lang.Integer"); + UnifyType voidType = tf.getSimpleType("void"); + UnifyType bool = tf.getSimpleType("java.lang.Boolean"); + UnifyType object = tf.getSimpleType("Object"); + UnifyType main = tf.getSimpleType("Main"); + UnifyType ol = tf.getSimpleType("OL"); + + fcb.add(integer, object); + fcb.add(main, object); + fcb.add(bool, object); + fcb.add(voidType, object); + fcb.add(ol, object); + + IFiniteClosure fc = fcb.getFiniteClosure(); + + Set eq = new HashSet(); + eq.add(new UnifyPair(tphT1, integer, PairOperator.SMALLERDOT)); + eq.add(new UnifyPair(integer, integer, PairOperator.SMALLERDOT)); + eq.add(new UnifyPair(tphT1, tphT2, PairOperator.SMALLERDOT)); + eq.add(new UnifyPair(tphT2, integer, PairOperator.SMALLERDOT)); + + eq.add(new UnifyPair(tphT3, bool, PairOperator.SMALLERDOT)); + eq.add(new UnifyPair(voidType, tphT4, PairOperator.SMALLERDOT)); + eq.add(new UnifyPair(ol, object, PairOperator.SMALLERDOT)); + eq.add(new UnifyPair(voidType, voidType, PairOperator.SMALLERDOT)); + eq.add(new UnifyPair(ol, tphT5, PairOperator.SMALLERDOT)); + eq.add(new UnifyPair(tphT5, ol, PairOperator.SMALLERDOT)); + + Set> expected = new HashSet<>(); + Set> actual = unify(eq, fc); + + System.out.println("Test Void:"); + System.out.println(actual); + } + @Test public void unifyTestSubclasses() { /*