3 import Analysis.OwnershipAnalysis.*;
10 protected static void test( String test,
14 String outcome = "...\tFAILED";
15 if( expected == result ) {
16 outcome = "...\tpassed";
19 System.out.println( test+" expected "+expected+outcome );
22 public static void main(String args[]) throws Exception {
25 OwnershipNode n0 = new OwnershipNode( new Integer( 1 ) );
26 OwnershipNode n1 = new OwnershipNode( new Integer( 1 ) );
27 OwnershipNode n2 = new OwnershipNode( new Integer( 2 ) );
29 test( "n0 equals n1?", true, n0.equals( n1 ) );
30 test( "n0 equals n2?", false, n0.equals( n2 ) );
31 test( "n1 equals n2?", false, n1.equals( n2 ) );
36 // ownership graphs g3 and g4 are equivalent
37 // graphs as specified in OwnershipGraph.java,
38 // just built different objects that contain the
39 // equivalent values and merged in a different
43 OwnershipGraph g0 = new OwnershipGraph( newDepthK );
44 TempDescriptor g0tdp1 = new TempDescriptor( "p1" );
45 TempDescriptor g0tdx = new TempDescriptor( "x" );
46 g0.parameterAllocation( g0tdp1 );
47 g0.assignTempToTemp ( g0tdx, g0tdp1 );
49 OwnershipGraph g1 = new OwnershipGraph( newDepthK );
50 TempDescriptor g1tdp2 = new TempDescriptor( "p2" );
51 TempDescriptor g1tdy = new TempDescriptor( "y" );
52 TempDescriptor g1tdz = new TempDescriptor( "z" );
53 g1.parameterAllocation( g1tdp2 );
54 g1.assignTempToTemp ( g1tdy, g1tdp2 );
55 g1.assignTempToField ( g1tdz, g1tdp2, null );
57 OwnershipGraph g2 = new OwnershipGraph( newDepthK );
58 TempDescriptor g2tdp3 = new TempDescriptor( "p3" );
59 TempDescriptor g2tdp4 = new TempDescriptor( "p4" );
60 TempDescriptor g2tdw = new TempDescriptor( "w" );
61 g2.parameterAllocation( g2tdp3 );
62 g2.parameterAllocation( g2tdp4 );
63 g2.assignTempToTemp ( g2tdw, g2tdp4 );
64 g2.assignFieldToTemp ( g2tdp3, g2tdw, null );
66 OwnershipGraph g3 = new OwnershipGraph( newDepthK );
71 OwnershipGraph g4 = new OwnershipGraph( newDepthK );
76 test( "4 == 5?", false, 4 == 5 );
77 test( "3 == 3?", true, 3 == 3 );
79 test( "g0 equals to g1?", false, g0.equals( g1 ) );
80 test( "g1 equals to g0?", false, g1.equals( g0 ) );
82 test( "g0 equals to g2?", false, g0.equals( g2 ) );
83 test( "g2 equals to g0?", false, g2.equals( g0 ) );
85 test( "g1 equals to g2?", false, g1.equals( g2 ) );
86 test( "g2 equals to g1?", false, g2.equals( g1 ) );
88 test( "g3 equals to g0?", false, g3.equals( g0 ) );
89 test( "g3 equals to g1?", false, g3.equals( g1 ) );
90 test( "g3 equals to g2?", false, g3.equals( g2 ) );
92 test( "g4 equals to g0?", false, g4.equals( g0 ) );
93 test( "g4 equals to g1?", false, g4.equals( g1 ) );
94 test( "g4 equals to g2?", false, g4.equals( g2 ) );
96 test( "g3 equals to g4?", true, g3.equals( g4 ) );
97 test( "g4 equals to g3?", true, g4.equals( g3 ) );