01: //Copyright (c) Hans-Joachim Daniels 2005
02: //
03: //This program is free software; you can redistribute it and/or modify
04: //it under the terms of the GNU General Public License as published by
05: //the Free Software Foundation; either version 2 of the License, or
06: //(at your option) any later version.
07: //
08: //This program is distributed in the hope that it will be useful,
09: //but WITHOUT ANY WARRANTY; without even the implied warranty of
10: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11: //GNU General Public License for more details.
12: //
13: //You can either finde the file LICENSE or LICENSE.TXT in the source
14: //distribution or in the .jar file of this application
15:
16: package de.uka.ilkd.key.ocl.gf;
17:
18: import junit.framework.Test;
19: import junit.framework.TestCase;
20: import junit.framework.TestSuite;
21:
22: public class TestGfAstNode extends TestCase {
23: public static Test suite() {
24: TestSuite suite = new TestSuite();
25: suite.addTest(new TestGfAstNode());
26: return suite;
27: }
28:
29: public static void main(String args[]) {
30: junit.textui.TestRunner.run(suite());
31: }
32:
33: public void setUp() {
34: //nothing to be done here
35: }
36:
37: public void testConstructor() {
38: String[] lines = {
39: "?1 : Sent",
40: "Two : Instance Integer",
41: "?3 : Instance (Collection (?{this:=this{-0-}}))",
42: "NOPACKAGEP_StartC_Constr : Constraint {Constraint<>NOPACKAGEP_StartC_Constr (\\this -> invCt ?)}",
43: "\\(this : VarSelf NOPACKAGEP_StartC) -> invCt : ClassConstraintBody",
44: "\\(x_0 : Instance Integer) -> ?6 : Sent",
45: "\\(selfGF : VarSelf NOPACKAGEP_PayCardC),(amount : Instance Integer) -> preC : OperConstraintBody",
46: "\\(selfGF : VarSelf NOPACKAGEP_PayCardC),(amount : Instance Integer) -> ?0 : OperConstraintBody" };
47: String[] funs = { "?1", "Two", "?3",
48: "NOPACKAGEP_StartC_Constr", "invCt", "?6", "preC", "?0" };
49: String[] types = { "Sent", "Instance Integer",
50: "Instance (Collection (?{this:=this{-0-}}))",
51: "Constraint", "ClassConstraintBody", "Sent",
52: "OperConstraintBody", "OperConstraintBody" };
53: String[] constraints = {
54: "",
55: "",
56: "",
57: "{Constraint<>NOPACKAGEP_StartC_Constr (\\this -> invCt ?)}",
58: "", "", "", "", "" };
59: for (int i = 0; i < lines.length; i++) {
60: //System.out.println("* " + lines[i]);
61: GfAstNode gfa = new GfAstNode(lines[i]);
62: assertTrue(" fun mismatch: expected '" + funs[i]
63: + "', got '" + gfa.getFun() + "'", gfa.getFun()
64: .equals(funs[i]));
65: assertEquals(gfa.getType(), types[i]);
66: assertEquals(gfa.constraint, constraints[i]);
67: }
68: }
69: }
|