Skip to content

Commit

Permalink
Added use of Groovy to test if the output compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Oct 17, 2010
1 parent 013342f commit 3d20d92
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<classpathentry exported="true" kind="lib" path="develjar/junit-4.5.jar"/>
<classpathentry kind="lib" path="jar/cmlxom-2.5-b1.jar"/>
<classpathentry kind="lib" path="develjar/ojdcheck.jar"/>
<classpathentry kind="lib" path="develjar/asm-3.1.jar"/>
<classpathentry kind="lib" path="develjar/groovy.jar"/>
<classpathentry kind="lib" path="develjar/antlr.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="jar/signatures-1.0.jar"/>
<classpathentry kind="lib" path="jar/jena/jena.jar"/>
Expand Down
Binary file added develjar/antlr.jar
Binary file not shown.
Binary file added develjar/groovy.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion src/META-INF/test-io.devellibdepends
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
junit-4.5.jar

groovy.jar
asm-3.1.jar
antlr.jar
23 changes: 17 additions & 6 deletions src/test/org/openscience/cdk/io/CDKSourceCodeWriterTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* $Revision$ $Author$ $Date$
/* Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project
* 2010 Egon Willighagen <egonw@users.sf.net>
*
* Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project
*
* Contact: cdk-devel@slists.sourceforge.net
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
Expand All @@ -12,18 +11,20 @@
* - but is not limited to - adding the above copyright notice to the beginning
* of your source code files, and to any copyright notice that you may distribute
* with programs based on this work.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.openscience.cdk.io;

import groovy.lang.GroovyShell;

import java.io.StringWriter;

import org.junit.Assert;
Expand Down Expand Up @@ -62,5 +63,15 @@ public class CDKSourceCodeWriterTest extends ChemObjectIOTest {
sourceWriter.write(molecule);
String output = writer.toString();
Assert.assertTrue(output.indexOf("IAtom a1 = mol.getNewBuilder().newInstance(IAtom.class,\"C\")") != -1);

GroovyShell shell = new GroovyShell();
shell.evaluate(
// import the classes used in the output
"import org.openscience.cdk.interfaces.*;" +
"import org.openscience.cdk.*;" +
// compensate for the write to wrap the output in { ... }
"if (true) " +
output
);
}
}

0 comments on commit 3d20d92

Please sign in to comment.