📄 unicode2test.java
字号:
package gls.ch03.s01;import junit.framework.*;import org.codehaus.groovy.tck.*;public class Unicode2Test extends TestCase { public void testPass() throws Throwable { StringBuffer srcBuffer = new StringBuffer(); srcBuffer.append("package gls.ch03.s01;").append(lineSep); srcBuffer.append("/**").append(lineSep); srcBuffer.append(" * Except for comments, identifiers and the contents of ... string ").append(lineSep); srcBuffer.append(" * literals, all input elements are formed from ASCII characters.").append(lineSep); srcBuffer.append(" *").append(lineSep); srcBuffer.append(" * TODO: Find a better way to test these things").append(lineSep); srcBuffer.append(" * Note that this is a little hard to test since the input file is ASCII.").append(lineSep); srcBuffer.append(" *").append(lineSep); srcBuffer.append(" * @author Jeremy Rayner").append(lineSep); srcBuffer.append(" */").append(lineSep); srcBuffer.append("").append(lineSep); srcBuffer.append("class Unicode2 extends GroovyTestCase {").append(lineSep); srcBuffer.append("").append(lineSep); srcBuffer.append("//todo - this doesn't seem to work in raw Java5.0 either").append(lineSep); srcBuffer.append("// public void testUTF16SupplementaryCharacters() {").append(lineSep); srcBuffer.append("// assert 1 == \"\\uD840\\uDC00\".length()").append(lineSep); srcBuffer.append("// }").append(lineSep); srcBuffer.append("").append(lineSep); srcBuffer.append(" public void testIdentifiers() {").append(lineSep); srcBuffer.append(" def foo\\u0044 = 12").append(lineSep); srcBuffer.append(" assert 20 == foo\\u0044 + 8").append(lineSep); srcBuffer.append(" }").append(lineSep); srcBuffer.append("}").append(lineSep); srcBuffer.append("").append(lineSep); Object result = helper.evaluate(srcBuffer.toString(),"testPass"); if (result instanceof TestResult) { TestResult testResult = (TestResult)result; if (testResult.errorCount() > 0) { TestFailure firstTestFailure = (TestFailure)testResult.errors().nextElement(); throw firstTestFailure.thrownException(); } if (testResult.failureCount() > 0) { AssertionFailedError firstFailure = (AssertionFailedError)(testResult.failures().nextElement()); throw firstFailure; } } } protected String lineSep = System.getProperty("line.separator"); protected TestGeneratorHelper helper = new ClassicGroovyTestGeneratorHelper();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -