From b972f6e6a121b78d883ee734ee74478474a5dd62 Mon Sep 17 00:00:00 2001 From: jjenista Date: Thu, 6 Mar 2008 21:53:26 +0000 Subject: [PATCH] Update parts of test to validate ownership graph operations. --- .../testGraphs/Main.java | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/Robust/src/Tests/OwnershipAnalysisTest/testGraphs/Main.java b/Robust/src/Tests/OwnershipAnalysisTest/testGraphs/Main.java index 0df31d60..d089f3af 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/testGraphs/Main.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/testGraphs/Main.java @@ -21,61 +21,69 @@ public class Main { public static void main(String args[]) throws Exception { - /* - OwnershipNode n0 = new OwnershipNode( new Integer( 1 ) ); - OwnershipNode n1 = new OwnershipNode( new Integer( 1 ) ); - OwnershipNode n2 = new OwnershipNode( new Integer( 2 ) ); - - test( "n0 equals n1?", true, n0.equals( n1 ) ); - test( "n0 equals n2?", false, n0.equals( n2 ) ); - test( "n1 equals n2?", false, n1.equals( n2 ) ); - */ + // example test to know the testing routine is correct! + test( "4 == 5?", false, 4 == 5 ); + test( "3 == 3?", true, 3 == 3 ); + + + // test equality of label objects that are logically + // same/different but all separate objects + // these tests show how a label node object or other + // ownership graph element can be equivalent logically + // to a different object in another graph + TempDescriptor lnTestA = new TempDescriptor( "lnTestA" ); + TempDescriptor lnTestB = new TempDescriptor( "lnTestB" ); + LabelNode ln0 = new LabelNode( lnTestA ); + LabelNode ln1 = new LabelNode( lnTestA ); + LabelNode ln2 = new LabelNode( lnTestB ); + + test( "ln0 equals ln1?", true, ln0.equals( ln1 ) ); + test( "ln1 equals ln0?", true, ln1.equals( ln0 ) ); + test( "ln0 equals ln2?", false, ln0.equals( ln2 ) ); + test( "ln2 equals ln1?", false, ln2.equals( ln1 ) ); // ownership graphs g3 and g4 are equivalent // graphs as specified in OwnershipGraph.java, - // just built different objects that contain the + // just built from different objects that contain the // equivalent values and merged in a different // order - int newDepthK = 3; + int allocationDepth = 3; - OwnershipGraph g0 = new OwnershipGraph( newDepthK ); + OwnershipGraph g0 = new OwnershipGraph( allocationDepth ); TempDescriptor g0tdp1 = new TempDescriptor( "p1" ); TempDescriptor g0tdx = new TempDescriptor( "x" ); - g0.parameterAllocation( g0tdp1 ); + g0.parameterAllocation( true, g0tdp1 ); g0.assignTempToTemp ( g0tdx, g0tdp1 ); - OwnershipGraph g1 = new OwnershipGraph( newDepthK ); + OwnershipGraph g1 = new OwnershipGraph( allocationDepth ); TempDescriptor g1tdp2 = new TempDescriptor( "p2" ); TempDescriptor g1tdy = new TempDescriptor( "y" ); TempDescriptor g1tdz = new TempDescriptor( "z" ); - g1.parameterAllocation( g1tdp2 ); + g1.parameterAllocation( true, g1tdp2 ); g1.assignTempToTemp ( g1tdy, g1tdp2 ); g1.assignTempToField ( g1tdz, g1tdp2, null ); - OwnershipGraph g2 = new OwnershipGraph( newDepthK ); + OwnershipGraph g2 = new OwnershipGraph( allocationDepth ); TempDescriptor g2tdp3 = new TempDescriptor( "p3" ); TempDescriptor g2tdp4 = new TempDescriptor( "p4" ); TempDescriptor g2tdw = new TempDescriptor( "w" ); - g2.parameterAllocation( g2tdp3 ); - g2.parameterAllocation( g2tdp4 ); + g2.parameterAllocation( true, g2tdp3 ); + g2.parameterAllocation( true, g2tdp4 ); g2.assignTempToTemp ( g2tdw, g2tdp4 ); g2.assignFieldToTemp ( g2tdp3, g2tdw, null ); - OwnershipGraph g3 = new OwnershipGraph( newDepthK ); + OwnershipGraph g3 = new OwnershipGraph( allocationDepth ); g3.merge( g0 ); g3.merge( g1 ); g3.merge( g2 ); - OwnershipGraph g4 = new OwnershipGraph( newDepthK ); + OwnershipGraph g4 = new OwnershipGraph( allocationDepth ); g4.merge( g1 ); g4.merge( g2 ); g4.merge( g0 ); - test( "4 == 5?", false, 4 == 5 ); - test( "3 == 3?", true, 3 == 3 ); - test( "g0 equals to g1?", false, g0.equals( g1 ) ); test( "g1 equals to g0?", false, g1.equals( g0 ) ); -- 2.34.1