mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Move to ANTLR 4 with Java 11 lang features and localization. (#5)
* Move to ANTLR 4 with Java 11 lang features and localization. Introduces ANTLR4 and Java 8 language feature support within IDE while also adding additional hooks for localization of syntax error messages, addressing https://github.com/processing/processing/issues/3054 and https://github.com/processing/processing/issues/3055. The PR is broadly a continuation of https://github.com/processing/processing/issues/3055, bringing it up to speed with the latest Processing master plus the changes introduced at https://github.com/processing/processing/pull/5753. **Requires https://github.com/processing/processing/pull/5753 as pre-requisite.** This introduces a number of edits beyond https://github.com/processing/processing/issues/3055 beyond compatibility with current Processing master and https://github.com/processing/processing/pull/5753 including: - Update to the grammar itself - Change ANTLR listeners to emit `TextTransform.Edit` to unify JDT-based `PreprocessingService` and `JavaBuild`, removing code with duplicate purpose. - Introduction of syntax error rewriting with support for localization. - Addition of complete localized strings set for English and Spanish. - Addition of partial localized strings set for other languages. - Refactor of ANTLR-related code for testability and readability - Expansion of tests including full parse tests for new Java features (type inference, lambdas). * Ask travis for ant upgrade prior to run. * Ask Travis for java11 update. * Add openjdk ppa * Travis no confirmation on add ppa. * Force newer ant on travis. * Swtich ant download to www-us mirror. * Switch ant to 1.10.7 * Start x for unit tests in travis. * More complete start x in travis. * Revert x in travis. * Try x in services.
This commit is contained in:
committed by
GitHub
parent
00dd2803f0
commit
ee299ef935
Binary file not shown.
@@ -0,0 +1,64 @@
|
||||
package processing.mode.java;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static processing.mode.java.ProcessingTestUtil.res;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AutoFormatTests {
|
||||
|
||||
@BeforeClass
|
||||
public static void init() {
|
||||
ProcessingTestUtil.init();
|
||||
}
|
||||
|
||||
static void expectGood(final String id) {
|
||||
try {
|
||||
final String formattedProgram = ProcessingTestUtil.format(res(id + ".pde"));
|
||||
final File goldenFile = res(id + ".expected");
|
||||
checkGolden(formattedProgram, goldenFile);
|
||||
// check that the formatted text doesn't change
|
||||
checkGolden(ProcessingTestUtil.format(formattedProgram), goldenFile);
|
||||
} catch (Exception e) {
|
||||
if (!e.equals(e.getCause()) && e.getCause() != null)
|
||||
fail(e.getCause().toString());
|
||||
else
|
||||
e.printStackTrace(System.err);
|
||||
fail(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkGolden(final String expectedText,
|
||||
final File goldenFile) throws IOException {
|
||||
if (goldenFile.exists()) {
|
||||
final String expected = ProcessingTestUtil.read(goldenFile);
|
||||
assertEquals(expected, expectedText);
|
||||
} else {
|
||||
System.err.println("WARN: golden file " + goldenFile
|
||||
+ " does not exist. Generating.");
|
||||
final FileWriter sug = new FileWriter(goldenFile);
|
||||
sug.write(ProcessingTestUtil.normalize(expectedText));
|
||||
sug.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug109() {
|
||||
expectGood("bug109");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug405() {
|
||||
expectGood("bug405");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug420() {
|
||||
expectGood("bug420");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
package processing.mode.java;
|
||||
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static processing.mode.java.ProcessingTestUtil.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.jdt.core.compiler.IProblem;
|
||||
import org.eclipse.jdt.core.dom.AST;
|
||||
import org.eclipse.jdt.core.dom.ASTParser;
|
||||
import org.eclipse.jdt.core.dom.CompilationUnit;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import processing.app.SketchException;
|
||||
import processing.mode.java.pdex.JdtCompilerUtil;
|
||||
import processing.mode.java.preproc.PreprocessorResult;
|
||||
import processing.mode.java.preproc.issue.PdePreprocessIssueException;
|
||||
|
||||
|
||||
public class ParserTests {
|
||||
|
||||
@BeforeClass
|
||||
public static void init() {
|
||||
ProcessingTestUtil.init();
|
||||
}
|
||||
|
||||
static void expectRecognitionException(final String id,
|
||||
final int expectedLine) {
|
||||
|
||||
PreprocessorResult result;
|
||||
try {
|
||||
preprocess(id, res(id + ".pde"));
|
||||
fail("Expected to fail with on line " + expectedLine);
|
||||
} catch (PdePreprocessIssueException e) {
|
||||
assertNotNull(e.getIssue().getMsg());
|
||||
assertEquals(expectedLine, e.getIssue().getLine());
|
||||
} catch (Exception e) {
|
||||
if (!e.equals(e.getCause()) && e.getCause() != null)
|
||||
fail(e.getCause().toString());
|
||||
else
|
||||
fail(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
static void expectRunnerException(final String id,
|
||||
final int expectedLine) {
|
||||
|
||||
try {
|
||||
preprocess(id, res(id + ".pde"));
|
||||
fail("Expected to fail with on line " + expectedLine);
|
||||
} catch (SketchException e) {
|
||||
assertEquals(expectedLine, e.getCodeLine());
|
||||
} catch (PdePreprocessIssueException e) {
|
||||
assertNotNull(e.getIssue().getMsg());
|
||||
assertEquals(expectedLine, e.getIssue().getLine());
|
||||
} catch (Exception e) {
|
||||
if (!e.equals(e.getCause()) && e.getCause() != null)
|
||||
fail(e.getCause().toString());
|
||||
else
|
||||
fail(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
static void expectCompilerException(final String id) {
|
||||
try {
|
||||
final String program = preprocess(id, res(id + ".pde"));
|
||||
boolean succeeded = compile(id, program);
|
||||
if (succeeded) {
|
||||
fail("Expected to fail.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (!e.equals(e.getCause()) && e.getCause() != null)
|
||||
fail(e.getCause().toString());
|
||||
else
|
||||
fail(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
static void expectGood(final String id) {
|
||||
expectGood(id, true);
|
||||
}
|
||||
|
||||
static void expectGood(final String id, boolean ignoreWhitespace) {
|
||||
try {
|
||||
final String program = preprocess(id, res(id + ".pde"));
|
||||
boolean successful = compile(id, program);
|
||||
if (successful) {
|
||||
System.err.println("----------------------------");
|
||||
System.err.println(program);
|
||||
System.err.println("----------------------------");
|
||||
fail("Compilation failed.");
|
||||
}
|
||||
|
||||
final File expectedFile = res(id + ".expected");
|
||||
if (expectedFile.exists()) {
|
||||
final String expected = ProcessingTestUtil.read(expectedFile);
|
||||
if (ignoreWhitespace) {
|
||||
String expectedStrip = expected.replace("\t", "")
|
||||
.replace(" ", "")
|
||||
.replace("\n", "")
|
||||
.replace("\r", "");
|
||||
|
||||
String actualStrip = program.replace("\t", "")
|
||||
.replace(" ", "")
|
||||
.replace("\n", "")
|
||||
.replace("\r", "");
|
||||
|
||||
if (!expectedStrip.equals(actualStrip)) {
|
||||
System.err.println("Expected >>>>>>>");
|
||||
System.err.println(expected);
|
||||
System.err.println("<<<<<<< Got >>>>>>>");
|
||||
System.err.println(program);
|
||||
System.err.println("<<<<<<<");
|
||||
assertEquals(expectedStrip, actualStrip);
|
||||
}
|
||||
} else {
|
||||
assertEquals(expected, program);
|
||||
}
|
||||
} else {
|
||||
System.err.println("WARN: " + id
|
||||
+ " does not have an expected output file. Generating.");
|
||||
final FileWriter sug = new FileWriter(res(id + ".expected"));
|
||||
sug.write(ProcessingTestUtil.normalize(program));
|
||||
sug.close();
|
||||
}
|
||||
|
||||
} catch (SketchException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug4() {
|
||||
expectGood("bug4");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug5a() {
|
||||
expectGood("bug5a");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug5b() {
|
||||
expectGood("bug5b");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug6() {
|
||||
expectRecognitionException("bug6", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug16() {
|
||||
expectRunnerException("bug16", 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug136() {
|
||||
expectGood("bug136", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug196() {
|
||||
expectRecognitionException("bug196", 5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug281() {
|
||||
expectGood("bug281");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug481() {
|
||||
expectGood("bug481");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug507() {
|
||||
expectRecognitionException("bug507", 5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug598() {
|
||||
expectGood("bug598");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug631() {
|
||||
expectGood("bug631");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug763() {
|
||||
expectRunnerException("bug763", 8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug820() {
|
||||
expectCompilerException("bug820");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1064() {
|
||||
expectGood("bug1064");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1145() {
|
||||
expectCompilerException("bug1145");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1362() {
|
||||
expectGood("bug1362");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1390() {
|
||||
expectGood("bug1390");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1442() {
|
||||
expectGood("bug1442");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1511() {
|
||||
expectGood("bug1511");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1512() {
|
||||
expectGood("bug1512");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1514a() {
|
||||
expectGood("bug1514a");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1514b() {
|
||||
expectGood("bug1514b");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1515() {
|
||||
expectGood("bug1515");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1516() {
|
||||
expectGood("bug1516");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1517() {
|
||||
expectGood("bug1517");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1518a() {
|
||||
expectGood("bug1518a");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1518b() {
|
||||
expectGood("bug1518b");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1525() {
|
||||
expectGood("bug1525");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1532() {
|
||||
expectRecognitionException("bug1532", 50);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1534() {
|
||||
expectGood("bug1534");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1936() {
|
||||
expectGood("bug1936");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug315g() {
|
||||
expectGood("bug315g");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug400g() {
|
||||
expectGood("bug400g", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug427g() {
|
||||
expectGood("bug427g");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void color() {
|
||||
expectGood("color", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void annotations() {
|
||||
expectGood("annotations", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generics() {
|
||||
expectGood("generics", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lambda() {
|
||||
expectGood("lambdaexample", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specialMethods() {
|
||||
expectGood("speicalmethods", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specialMethodsPrivate() {
|
||||
expectGood("specialmethodsprivate", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classInStatic() {
|
||||
expectGood("classinstatic", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fullscreen() {
|
||||
expectGood("fullscreen", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customMain() {
|
||||
expectGood("custommain", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void charSpecial() {
|
||||
expectGood("charspecial", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void typeInference() {
|
||||
expectGood("typeinference");
|
||||
}
|
||||
|
||||
private static boolean compile(String id, String program) {
|
||||
// Create compilable AST to get syntax problems
|
||||
CompilationUnit compilableCU = JdtCompilerUtil.makeAST(
|
||||
ASTParser.newParser(AST.JLS8),
|
||||
program.toCharArray(),
|
||||
JdtCompilerUtil.COMPILER_OPTIONS
|
||||
);
|
||||
|
||||
// Get syntax problems from compilable AST
|
||||
Optional<IProblem> problem = Arrays.stream(compilableCU.getProblems())
|
||||
.filter(IProblem::isError)
|
||||
.findFirst();
|
||||
|
||||
if (problem.isPresent()) {
|
||||
IProblem problemFound = problem.get();
|
||||
|
||||
System.err.println("Compilation issue: "
|
||||
+ problemFound.getMessage()
|
||||
+ "(" + problemFound.getSourceLineNumber() + ")"
|
||||
);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package processing.mode.java;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringWriter;
|
||||
import processing.app.Preferences;
|
||||
import processing.app.SketchException;
|
||||
import processing.mode.java.preproc.PdePreprocessor;
|
||||
import processing.mode.java.preproc.PreprocessorResult;
|
||||
import processing.mode.java.preproc.issue.PdePreprocessIssueException;
|
||||
|
||||
|
||||
public class ProcessingTestUtil {
|
||||
static void init() {
|
||||
// noop; just causes class to be loaded
|
||||
}
|
||||
|
||||
private static final String RESOURCES = "test/resources/";
|
||||
private static final String RESOURCES_UP_DIR = "../java/test/resources";
|
||||
static final UTCompiler COMPILER;
|
||||
|
||||
static {
|
||||
try {
|
||||
COMPILER = new UTCompiler(new File("bin-test"), new File("../core/bin"));
|
||||
Preferences.load(new FileInputStream(res("preferences.txt")));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
//System.err.println("ProcessingTestUtil initialized.");
|
||||
}
|
||||
|
||||
static String normalize(final Object s) {
|
||||
return String.valueOf(s).replace("\r", "");
|
||||
}
|
||||
|
||||
static String preprocess(final String name, final File resource)
|
||||
throws SketchException {
|
||||
final String program = read(resource);
|
||||
final StringWriter out = new StringWriter();
|
||||
PreprocessorResult result = new PdePreprocessor(name, 4, true).write(out, program);
|
||||
|
||||
if (result.getPreprocessIssues().size() > 0) {
|
||||
throw new PdePreprocessIssueException(result.getPreprocessIssues().get(0));
|
||||
}
|
||||
|
||||
return normalize(out);
|
||||
}
|
||||
|
||||
static String format(final File resource)
|
||||
{
|
||||
return format(read(resource));
|
||||
}
|
||||
|
||||
static String format(final String programText) {
|
||||
return normalize(new AutoFormat().format(programText));
|
||||
}
|
||||
|
||||
static File res(final String resourceName) {
|
||||
File target = new File(RESOURCES, resourceName);
|
||||
if (target.exists()) {
|
||||
return target;
|
||||
}
|
||||
return new File(RESOURCES_UP_DIR, resourceName);
|
||||
}
|
||||
|
||||
static String read(final File f) {
|
||||
try {
|
||||
final FileInputStream fin = new FileInputStream(f);
|
||||
final InputStreamReader in = new InputStreamReader(fin, "UTF-8");
|
||||
try {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final char[] buf = new char[1 << 12];
|
||||
int len;
|
||||
while ((len = in.read(buf)) != -1)
|
||||
sb.append(buf, 0, len);
|
||||
return normalize(sb);
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Unexpected", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package processing.mode.java;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import processing.app.Platform;
|
||||
import processing.app.exec.ProcessHelper;
|
||||
import processing.app.exec.ProcessResult;
|
||||
|
||||
/**
|
||||
* Utility class for compiling single compilationUnits.
|
||||
*
|
||||
* @author Jonathan Feinberg <jdf@pobox.com>
|
||||
*
|
||||
*/
|
||||
class UTCompiler {
|
||||
private final String classpath;
|
||||
|
||||
UTCompiler(File... classpath) throws IOException {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (final File f : classpath) {
|
||||
if (sb.length() > 0)
|
||||
sb.append(File.pathSeparatorChar);
|
||||
sb.append(f.getAbsolutePath());
|
||||
}
|
||||
this.classpath = sb.toString();
|
||||
}
|
||||
|
||||
ProcessResult compile(final String name, final String program)
|
||||
throws IOException {
|
||||
final File tmpdir = File.createTempFile("utcompiler", ".tmp");
|
||||
if (!tmpdir.delete())
|
||||
throw new IOException("Cannot delete " + tmpdir);
|
||||
if (!tmpdir.mkdir())
|
||||
throw new IOException("Cannot create " + tmpdir);
|
||||
final File javaFile = new File(tmpdir, name + ".java");
|
||||
final FileWriter java = new FileWriter(javaFile);
|
||||
try {
|
||||
java.write(program);
|
||||
} finally {
|
||||
java.close();
|
||||
}
|
||||
try {
|
||||
return new ProcessHelper("javac",
|
||||
"-sourcepath", tmpdir.getAbsolutePath(),
|
||||
"-cp", classpath,
|
||||
"-nowarn",
|
||||
"-d", tmpdir.getAbsolutePath(),
|
||||
javaFile.getAbsolutePath()).execute();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
for (final File f: tmpdir.listFiles())
|
||||
if (!f.getName().startsWith("."))if (!f.delete())
|
||||
throw new IOException("Can't delete " + f);
|
||||
if (!tmpdir.delete())
|
||||
throw new IOException("Can't delete " + tmpdir);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package processing.mode.java.pdex.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import processing.app.Problem;
|
||||
import processing.app.ui.Editor;
|
||||
import processing.mode.java.preproc.issue.PdePreprocessIssue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ProblemFactoryTest {
|
||||
|
||||
private PdePreprocessIssue pdePreprocessIssue;
|
||||
private List<Integer> tabStarts;
|
||||
private Editor editor;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
pdePreprocessIssue = new PdePreprocessIssue(8, 2, "test");
|
||||
|
||||
tabStarts = new ArrayList<>();
|
||||
tabStarts.add(5);
|
||||
|
||||
editor = Mockito.mock(Editor.class);
|
||||
Mockito.when(editor.getLineStartOffset(3)).thenReturn(10);
|
||||
Mockito.when(editor.getLineStopOffset(3)).thenReturn(12);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildWithEditor() {
|
||||
Problem problem = ProblemFactory.build(pdePreprocessIssue, tabStarts, 15, editor);
|
||||
|
||||
Assert.assertEquals(3, problem.getLineNumber());
|
||||
Assert.assertEquals("test", problem.getMessage());
|
||||
Assert.assertEquals(10, problem.getStartOffset());
|
||||
Assert.assertEquals(11, problem.getStopOffset());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildWithoutEditor() {
|
||||
Problem problem = ProblemFactory.build(pdePreprocessIssue, tabStarts);
|
||||
|
||||
Assert.assertEquals(3, problem.getLineNumber());
|
||||
Assert.assertEquals("test", problem.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package processing.mode.java.pdex.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TabLineFactoryTest {
|
||||
|
||||
private List<Integer> starts;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
starts = new ArrayList<>();
|
||||
starts.add(0);
|
||||
starts.add(5);
|
||||
starts.add(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabStart() {
|
||||
Assert.assertEquals(0, TabLineFactory.getTab(starts, 0).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddleFrontEdge() {
|
||||
Assert.assertEquals(1, TabLineFactory.getTab(starts, 5).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddle() {
|
||||
TabLine tabLine = TabLineFactory.getTab(starts, 7);
|
||||
Assert.assertEquals(1, tabLine.getTab());
|
||||
Assert.assertEquals(2, tabLine.getLineInTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabMiddleBackEdge() {
|
||||
Assert.assertEquals(2, TabLineFactory.getTab(starts, 10).getTab());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTabEnd() {
|
||||
Assert.assertEquals(2, TabLineFactory.getTab(starts, 15).getTab());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package processing.mode.java.preproc.code;
|
||||
|
||||
import org.antlr.v4.runtime.BufferedTokenStream;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.TokenStreamRewriter;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import processing.mode.java.pdex.TextTransform;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class CodeEditOperationUtilTest {
|
||||
|
||||
private TokenStreamRewriter tokenStreamRewriter;
|
||||
private Token sampleStart;
|
||||
private Token sampleEnd;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
tokenStreamRewriter = Mockito.mock(TokenStreamRewriter.class);
|
||||
|
||||
sampleStart = Mockito.mock(Token.class);
|
||||
Mockito.when(sampleStart.getStartIndex()).thenReturn(5);
|
||||
Mockito.when(sampleStart.getText()).thenReturn("test");
|
||||
|
||||
sampleEnd = Mockito.mock(Token.class);
|
||||
Mockito.when(sampleEnd.getStartIndex()).thenReturn(10);
|
||||
Mockito.when(sampleEnd.getText()).thenReturn("testing");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createDeleteSingle() {
|
||||
TextTransform.Edit edit = CodeEditOperationUtil.createDelete(sampleStart, tokenStreamRewriter);
|
||||
Assert.assertNotNull(edit);
|
||||
Mockito.verify(tokenStreamRewriter).delete(sampleStart);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createDeleteRange() {
|
||||
TextTransform.Edit edit = CodeEditOperationUtil.createDelete(
|
||||
sampleStart,
|
||||
sampleEnd,
|
||||
tokenStreamRewriter
|
||||
);
|
||||
|
||||
Assert.assertNotNull(edit);
|
||||
Mockito.verify(tokenStreamRewriter).delete(sampleStart, sampleEnd);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createInsertAfterLocation() {
|
||||
TextTransform.Edit edit = CodeEditOperationUtil.createInsertAfter(
|
||||
5,
|
||||
"text",
|
||||
tokenStreamRewriter
|
||||
);
|
||||
|
||||
Assert.assertNotNull(edit);
|
||||
Mockito.verify(tokenStreamRewriter).insertAfter(5, "text");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createInsertAfterToken() {
|
||||
TextTransform.Edit edit = CodeEditOperationUtil.createInsertAfter(
|
||||
sampleStart,
|
||||
"text",
|
||||
tokenStreamRewriter
|
||||
);
|
||||
|
||||
Assert.assertNotNull(edit);
|
||||
Mockito.verify(tokenStreamRewriter).insertAfter(sampleStart, "text");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createInsertBeforeToken() {
|
||||
TextTransform.Edit edit = CodeEditOperationUtil.createInsertBefore(
|
||||
sampleStart,
|
||||
"text",
|
||||
tokenStreamRewriter
|
||||
);
|
||||
|
||||
Assert.assertNotNull(edit);
|
||||
Mockito.verify(tokenStreamRewriter).insertBefore(sampleStart, "text");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createInsertBeforeLocation() {
|
||||
TextTransform.Edit edit = CodeEditOperationUtil.createInsertBefore(
|
||||
5,
|
||||
5,
|
||||
"text",
|
||||
tokenStreamRewriter
|
||||
);
|
||||
|
||||
Assert.assertNotNull(edit);
|
||||
Mockito.verify(tokenStreamRewriter).insertBefore(5, "text");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package processing.mode.java.preproc.code;
|
||||
|
||||
import org.antlr.v4.runtime.TokenStreamRewriter;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import processing.mode.java.pdex.TextTransform;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class PrintWriterWithEditGenTest {
|
||||
|
||||
private TokenStreamRewriter tokenStreamRewriter;
|
||||
private RewriteResultBuilder rewriteResultBuilder;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
tokenStreamRewriter = Mockito.mock(TokenStreamRewriter.class);
|
||||
rewriteResultBuilder = new RewriteResultBuilder();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addEmptyLineBefore() {
|
||||
PrintWriterWithEditGen editGen = createGen(true);
|
||||
editGen.addEmptyLine();
|
||||
editGen.finish();
|
||||
|
||||
List<TextTransform.Edit> edits = rewriteResultBuilder.getEdits();
|
||||
Assert.assertEquals(1, edits.size());
|
||||
|
||||
Mockito.verify(tokenStreamRewriter).insertBefore(5, "\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addCodeLineBefore() {
|
||||
PrintWriterWithEditGen editGen = createGen(true);
|
||||
editGen.addCodeLine("test");
|
||||
editGen.finish();
|
||||
|
||||
List<TextTransform.Edit> edits = rewriteResultBuilder.getEdits();
|
||||
Assert.assertEquals(1, edits.size());
|
||||
|
||||
Mockito.verify(tokenStreamRewriter).insertBefore(5, "test\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addCodeBefore() {
|
||||
PrintWriterWithEditGen editGen = createGen(true);
|
||||
editGen.addCode("test");
|
||||
editGen.finish();
|
||||
|
||||
List<TextTransform.Edit> edits = rewriteResultBuilder.getEdits();
|
||||
Assert.assertEquals(1, edits.size());
|
||||
|
||||
Mockito.verify(tokenStreamRewriter).insertBefore(5, "test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addEmptyLineAfter() {
|
||||
PrintWriterWithEditGen editGen = createGen(false);
|
||||
editGen.addEmptyLine();
|
||||
editGen.finish();
|
||||
|
||||
List<TextTransform.Edit> edits = rewriteResultBuilder.getEdits();
|
||||
Assert.assertEquals(1, edits.size());
|
||||
|
||||
Mockito.verify(tokenStreamRewriter).insertAfter(5, "\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addCodeLineAfter() {
|
||||
PrintWriterWithEditGen editGen = createGen(false);
|
||||
editGen.addCodeLine("test");
|
||||
editGen.finish();
|
||||
|
||||
List<TextTransform.Edit> edits = rewriteResultBuilder.getEdits();
|
||||
Assert.assertEquals(1, edits.size());
|
||||
|
||||
Mockito.verify(tokenStreamRewriter).insertAfter(5, "test\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addCodeAfter() {
|
||||
PrintWriterWithEditGen editGen = createGen(false);
|
||||
editGen.addCode("test");
|
||||
editGen.finish();
|
||||
|
||||
List<TextTransform.Edit> edits = rewriteResultBuilder.getEdits();
|
||||
Assert.assertEquals(1, edits.size());
|
||||
|
||||
Mockito.verify(tokenStreamRewriter).insertAfter(5, "test");
|
||||
}
|
||||
|
||||
private PrintWriterWithEditGen createGen(boolean before) {
|
||||
return new PrintWriterWithEditGen(
|
||||
tokenStreamRewriter,
|
||||
rewriteResultBuilder,
|
||||
5,
|
||||
before
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class AssignmentMessageSimplifierStrategyTest {
|
||||
|
||||
private AssignmentMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new AssignmentMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify(" int x =");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresentDiamond() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify(" List<Integer> x =");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("class {");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class BadIdentifierMessageSimplifierStrategyTest {
|
||||
|
||||
private BadIdentifierMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new BadIdentifierMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("test(a,01a");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("class {");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class BadParamMessageSimplifierStrategyTest {
|
||||
|
||||
private BadParamMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new BadParamMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("void test (int x,\ny) \n{");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresentUnderscore() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("void test (int x,\ny_y) \n{");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresentVarType() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("void test (int x,\nint) \n{");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("int x = y");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class ExtraneousInputMessageSimplifierStrategyTest {
|
||||
|
||||
private ExtraneousInputMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new ExtraneousInputMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("extraneous input 'test' expecting ';'");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("String x = \" \\\" \"");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class KnownMissingMessageSimplifierStrategyTest {
|
||||
|
||||
private KnownMissingMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new KnownMissingMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("missing ';' at 'addCircle'");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("String x = \" \\\" \"");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MessageSimplifierUtilTest {
|
||||
|
||||
@Test
|
||||
public void getOffendingAreaMatch() {
|
||||
String input = "no viable alternative at input 'ellipse(\n\nellipse();'";
|
||||
String output = MessageSimplifierUtil.getOffendingArea(input);
|
||||
Assert.assertEquals("ellipse();", output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOffendingAreaNoMatch() {
|
||||
String input = "ambig at input 'ellipse(\n\nellipse();'";
|
||||
String output = MessageSimplifierUtil.getOffendingArea(input);
|
||||
Assert.assertEquals("ambig at input 'ellipse(\n\nellipse();'", output);
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class MismatchedInputMessageSimplifierStrategyTest {
|
||||
|
||||
private MismatchedInputMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new MismatchedInputMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("mismatched input 'final' expecting {'instanceof', ';', ',', '.', '>', '<', '==', '<=', '>=', '!=', '&&', '||', '++', '--', '+', '-', '*', '/', '&', '|', '^', '%', '::'}");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("String x = \" \\\" \"");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class MissingChevMessageSimplifierStrategyTest {
|
||||
|
||||
private processing.mode.java.preproc.issue.strategy.MissingChevMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new MissingChevMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("class Test <a extends {");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("class {");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class MissingClassNameMessageSimplifierStrategyTest {
|
||||
|
||||
private MissingClassNameMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new MissingClassNameMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresentExtends() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("class extends Base\n{");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresentNoExtends() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("class \n{");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("int x = y");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class MissingCurlyMessageSimplifierStrategyTest {
|
||||
|
||||
private MissingCurlyMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new MissingCurlyMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("class Test {");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("class Test { }");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class MissingDoubleQuoteMessageSimplifierStrategyTest {
|
||||
|
||||
private MissingDoubleQuoteMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new MissingDoubleQuoteMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("String x = \" \" \"");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("String x = \" \\\" \"");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class MissingGenericTypeMessageSimplifierStrategyTest {
|
||||
|
||||
private MissingGenericTypeMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new MissingGenericTypeMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("<>'");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("class {");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class MissingIdentifierMessageSimplifierStrategyTest {
|
||||
|
||||
private MissingIdentifierMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new MissingIdentifierMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("Missing identifier at ';'");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("String x = \" \\\" \"");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class MissingMethodNameMessageSimplifierStrategyTest {
|
||||
|
||||
private MissingMethodNameMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new MissingMethodNameMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("void (int x) \n{");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresentNoSpace() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("test(int x) \n{");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresentUnderscore() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("void (int x_y) \n{");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("int x = y");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class MissingParenMessageSimplifierStrategyTest {
|
||||
|
||||
private MissingParenMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new MissingParenMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("int x = ((5 + 4) / 3");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("int x = (y/5)/(\n4)");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class MissingSingleQuoteMessageSimplifierStrategyTest {
|
||||
|
||||
private MissingSingleQuoteMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new MissingSingleQuoteMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("char x = '");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("char x = '\\''");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package processing.mode.java.preproc.issue.strategy;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class MissingVariableNameMessageSimplifierStrategyTest {
|
||||
|
||||
private MissingVariableNameMessageSimplifierStrategy strategy;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
strategy = new MissingVariableNameMessageSimplifierStrategy();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("char = ';");
|
||||
Assert.assertTrue(msg.isPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotPresent() {
|
||||
Optional<IssueMessageSimplification> msg = strategy.simplify("class test {");
|
||||
Assert.assertTrue(msg.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package processing.mode.java.preproc.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.IssueLocation;
|
||||
import processing.mode.java.preproc.issue.IssueLocationFactory;
|
||||
import processing.mode.java.preproc.issue.IssueMessageSimplification;
|
||||
|
||||
|
||||
public class IssueLocationFactoryTest {
|
||||
|
||||
private String source;
|
||||
private IssueLocation issueLocation;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
source = "//Test\n" +
|
||||
"noFill();\n" +
|
||||
"/**\n" +
|
||||
"**/\n" +
|
||||
"ellipse(50,50,50,50)\n" +
|
||||
"\n" +
|
||||
"/**\n" +
|
||||
"Test\n" +
|
||||
"* Test\n" +
|
||||
"** Test\n" +
|
||||
"*/\n" +
|
||||
"\n" +
|
||||
"// Testing\n" +
|
||||
"\n";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLineWithOffsetApplies() {
|
||||
issueLocation = IssueLocationFactory.getLineWithOffset(
|
||||
new IssueMessageSimplification("test message", true),
|
||||
15,
|
||||
0,
|
||||
source
|
||||
);
|
||||
|
||||
Assert.assertEquals(5, issueLocation.getLine());
|
||||
Assert.assertEquals(20, issueLocation.getCharPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLineWithOffsetNotApplies() {
|
||||
issueLocation = IssueLocationFactory.getLineWithOffset(
|
||||
new IssueMessageSimplification("test message", false),
|
||||
15,
|
||||
0,
|
||||
source
|
||||
);
|
||||
|
||||
Assert.assertEquals(15, issueLocation.getLine());
|
||||
Assert.assertEquals(0, issueLocation.getCharPosition());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getLineWithOffsetEndWhite() {
|
||||
issueLocation = IssueLocationFactory.getLineWithOffset(
|
||||
new IssueMessageSimplification("test message", true),
|
||||
14,
|
||||
0,
|
||||
"\n\n\n\n\n\n\n\n\n\n\nnoFill()\nellipse(50,50,50,50)\n"
|
||||
);
|
||||
|
||||
Assert.assertEquals(13, issueLocation.getLine());
|
||||
Assert.assertEquals(20, issueLocation.getCharPosition());
|
||||
}
|
||||
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package processing.mode.java.preproc.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.issue.PreprocessIssueMessageSimplifierFacade;
|
||||
|
||||
|
||||
public class PreprocessIssueMessageSimplifierFacadeTest {
|
||||
|
||||
@Test
|
||||
public void testAssignment() {
|
||||
String input = "List<ColoredCircle> =";
|
||||
String output = PreprocessIssueMessageSimplifierFacade.get().simplify(input).getMessage();
|
||||
Assert.assertTrue(output.contains("assignment"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadIdentifier() {
|
||||
String input = "List<ColoredCircle> 9";
|
||||
String output = PreprocessIssueMessageSimplifierFacade.get().simplify(input).getMessage();
|
||||
Assert.assertTrue(output.contains("digit"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadParamLead() {
|
||||
String input = "x,";
|
||||
String output = PreprocessIssueMessageSimplifierFacade.get().simplify(input).getMessage();
|
||||
Assert.assertTrue(output.contains("parameter"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadParamEnd() {
|
||||
String input = "colorGen),";
|
||||
String output = PreprocessIssueMessageSimplifierFacade.get().simplify(input).getMessage();
|
||||
Assert.assertTrue(output.contains("parameter"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCaret() {
|
||||
String input = "List<ColoredCircle circles";
|
||||
String output = PreprocessIssueMessageSimplifierFacade.get().simplify(input).getMessage();
|
||||
Assert.assertTrue(output.contains(">"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissingIdentifier() {
|
||||
String input = "missing Identifier at '{'";
|
||||
String output = PreprocessIssueMessageSimplifierFacade.get().simplify(input).getMessage();
|
||||
Assert.assertTrue(output.contains("{"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simplifyParen() {
|
||||
String input = "no viable alternative at input 'ellipse(\n\nellipse();'";
|
||||
String output = PreprocessIssueMessageSimplifierFacade.get().simplify(input).getMessage();
|
||||
Assert.assertNotNull(output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simplifySemicolon() {
|
||||
String input = "no viable alternative at input 'ellipse(\n\nellipse())'";
|
||||
String output = PreprocessIssueMessageSimplifierFacade.get().simplify(input).getMessage();
|
||||
Assert.assertNotNull(output);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package processing.mode.java.preproc.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import processing.mode.java.preproc.code.SyntaxUtil;
|
||||
|
||||
|
||||
public class SyntaxUtilTest {
|
||||
|
||||
@Test
|
||||
public void getCountPresent() {
|
||||
String input = "test1,test2\n,test3";
|
||||
int count = processing.mode.java.preproc.code.SyntaxUtil.getCount(input, ",");
|
||||
Assert.assertEquals(2, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCountNotPresent() {
|
||||
String input = "test1 test2 test3";
|
||||
int count = SyntaxUtil.getCount(input, ",");
|
||||
Assert.assertEquals(0, count);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class annotations extends PApplet {
|
||||
|
||||
|
||||
|
||||
public void setup() {
|
||||
/* size commented out by preprocessor */;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void banana() {
|
||||
println("hey");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"serial", "rawtypes"})
|
||||
class Banana implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class Apple implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
@javax.annotation.processing.Generated(value = {"com.mrfeinberg.ImmortalAroma"
|
||||
},
|
||||
comments="Shazam!",
|
||||
date="2001-07-04T12:08:56.235-0700")
|
||||
class Pear {}
|
||||
|
||||
|
||||
public void settings() { size(200,200); }
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "annotations" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import java.io.Serializable;
|
||||
|
||||
void setup() {
|
||||
size(200,200);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void banana() {
|
||||
println("hey");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"serial", "rawtypes"})
|
||||
class Banana implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class Apple implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
@javax.annotation.processing.Generated(value = {"com.mrfeinberg.ImmortalAroma"
|
||||
},
|
||||
comments="Shazam!",
|
||||
date="2001-07-04T12:08:56.235-0700")
|
||||
class Pear {}
|
||||
@@ -0,0 +1,30 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1064 extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
// import ";
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1064" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
// import ";
|
||||
@@ -0,0 +1,5 @@
|
||||
class Bug {
|
||||
Bug() {
|
||||
w = random(size)/3)+10;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
class Bug{
|
||||
Bug(){
|
||||
w = random(size)/3)+10;
|
||||
}}
|
||||
@@ -0,0 +1 @@
|
||||
import processing;
|
||||
@@ -0,0 +1,45 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug136 extends PApplet {
|
||||
|
||||
|
||||
java.util.List alist = Collections.synchronizedList(new ArrayList());
|
||||
|
||||
public void setup() {
|
||||
/* size commented out by preprocessor */;
|
||||
alist.add("hello");
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
rect(width/4, height/4, width/2, height/2);
|
||||
synchronized(alist) {
|
||||
alist.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void settings() { size(400,200); }
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug136" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import java.util.Collections;
|
||||
java.util.List alist = Collections.synchronizedList(new ArrayList());
|
||||
|
||||
void setup() {
|
||||
size(400, 200);
|
||||
alist.add("hello");
|
||||
}
|
||||
|
||||
void draw() {
|
||||
rect(width/4, height/4, width/2, height/2);
|
||||
synchronized(alist) {
|
||||
alist.get(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1362 extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
if (true) {} else { new String(); }
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1362" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
if (true) {} else { new String(); }
|
||||
@@ -0,0 +1,57 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.lang.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1390 extends PApplet {
|
||||
|
||||
|
||||
|
||||
enum Operation {
|
||||
@Deprecated ADD_10(10) { protected int apply(int x) { return x + y; } },
|
||||
MULT_5(5) { protected int apply(int x) { return x * y; } },
|
||||
@SuppressWarnings("serial") DIV_10(10) { protected int apply(int x) { return x / y; } },
|
||||
SUB_8(8) { protected int apply(int x) { return x - y; } };
|
||||
|
||||
final int y;
|
||||
|
||||
Operation(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
protected abstract int apply(int x);
|
||||
}
|
||||
|
||||
Operation operation = Operation.ADD_10;
|
||||
|
||||
public void setup() {
|
||||
int x = 10;
|
||||
println("Original:", x);
|
||||
for (Operation op : Operation.values()) {
|
||||
x = op.apply(x);
|
||||
println(op.toString(), x);
|
||||
}
|
||||
x = operation.apply(x);
|
||||
println(operation.toString(), x);
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1390" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import java.lang.*;
|
||||
|
||||
enum Operation {
|
||||
@Deprecated ADD_10(10) { protected int apply(int x) { return x + y; } },
|
||||
MULT_5(5) { protected int apply(int x) { return x * y; } },
|
||||
@SuppressWarnings("serial") DIV_10(10) { protected int apply(int x) { return x / y; } },
|
||||
SUB_8(8) { protected int apply(int x) { return x - y; } };
|
||||
|
||||
final int y;
|
||||
|
||||
Operation(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
protected abstract int apply(int x);
|
||||
}
|
||||
|
||||
Operation operation = Operation.ADD_10;
|
||||
|
||||
void setup() {
|
||||
int x = 10;
|
||||
println("Original:", x);
|
||||
for (Operation op : Operation.values()) {
|
||||
x = op.apply(x);
|
||||
println(op.toString(), x);
|
||||
}
|
||||
x = operation.apply(x);
|
||||
println(operation.toString(), x);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1442 extends PApplet {
|
||||
|
||||
public float a() {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1442" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
float a() {
|
||||
return 1.0;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1511 extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
// \u00df
|
||||
|
||||
/**
|
||||
* a
|
||||
*/
|
||||
|
||||
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1511" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// ß
|
||||
|
||||
/**
|
||||
* a
|
||||
*/
|
||||
|
||||
import java.io.StringWriter;
|
||||
@@ -0,0 +1,30 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1512 extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
println("oi/*");
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1512" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
println("oi/*");
|
||||
@@ -0,0 +1,36 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1514a extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
//----- \u00e8\u00e9\u00e9\u00e8\u00e8\u00e9\u00e9\u00e9\u00e0\u00e9\u00e9\u00e8\u00e9''\u00e9\u00e9\u00e9
|
||||
//----------------------------------------------------------------
|
||||
//--- IMPORTS
|
||||
//----------------------------------------------------------------
|
||||
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1514a" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
//----- èééèèéééàééèé''ééé
|
||||
//----------------------------------------------------------------
|
||||
//--- IMPORTS
|
||||
//----------------------------------------------------------------
|
||||
import java.io.StringWriter;
|
||||
@@ -0,0 +1,36 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1514b extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
//----- \u00e8\u00e9\u00e9\u00e8\u00e8\u00e9\u00e9\u00e9\u00e0\u00e9\u00e9\u00e8\u00e9''\u00e9\u00e9
|
||||
//----------------------------------------------------------------
|
||||
//--- IMPORTS
|
||||
//----------------------------------------------------------------
|
||||
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1514b" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
//----- èééèèéééàééèé''éé
|
||||
//----------------------------------------------------------------
|
||||
//--- IMPORTS
|
||||
//----------------------------------------------------------------
|
||||
import java.io.StringWriter;
|
||||
@@ -0,0 +1,33 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1515 extends PApplet {
|
||||
|
||||
// a class definition that does something with things that extend PApplet
|
||||
class Heythere<T extends PApplet>{
|
||||
}
|
||||
|
||||
// method definition which can do things with papplet
|
||||
public <T extends PApplet> void doSomething( T thing ){
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1515" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// a class definition that does something with things that extend PApplet
|
||||
class Heythere<T extends PApplet>{
|
||||
}
|
||||
|
||||
// method definition which can do things with papplet
|
||||
public <T extends PApplet> void doSomething( T thing ){
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1516 extends PApplet {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void setup()
|
||||
{
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add("foo");
|
||||
list.add("bar");
|
||||
list.add("baz");
|
||||
|
||||
Comparator<String> comparator = new Comparator<String>()
|
||||
{
|
||||
public int compare(final String value0, final String value1)
|
||||
{
|
||||
return value0.compareTo(value1);
|
||||
}
|
||||
};
|
||||
|
||||
Collections.sort(list, comparator);
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1516" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
void setup()
|
||||
{
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add("foo");
|
||||
list.add("bar");
|
||||
list.add("baz");
|
||||
|
||||
Comparator<String> comparator = new Comparator<String>()
|
||||
{
|
||||
public int compare(final String value0, final String value1)
|
||||
{
|
||||
return value0.compareTo(value1);
|
||||
}
|
||||
};
|
||||
|
||||
Collections.sort(list, comparator);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1517 extends PApplet {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Comparator<String> comparator = new Comparator<String>()
|
||||
{
|
||||
public int compare(final String value0, final String value1)
|
||||
{
|
||||
return value0.compareTo(value1);
|
||||
}
|
||||
};
|
||||
|
||||
public void setup()
|
||||
{
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add("foo");
|
||||
list.add("bar");
|
||||
list.add("baz");
|
||||
|
||||
Collections.sort(list, comparator);
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1517" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
Comparator<String> comparator = new Comparator<String>()
|
||||
{
|
||||
public int compare(final String value0, final String value1)
|
||||
{
|
||||
return value0.compareTo(value1);
|
||||
}
|
||||
};
|
||||
|
||||
void setup()
|
||||
{
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add("foo");
|
||||
list.add("bar");
|
||||
list.add("baz");
|
||||
|
||||
Collections.sort(list, comparator);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1518a extends PApplet {
|
||||
|
||||
|
||||
|
||||
|
||||
public void setup()
|
||||
{
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add("foo");
|
||||
list.add("bar");
|
||||
list.add("baz");
|
||||
|
||||
binarySearch(list, "bar");
|
||||
}
|
||||
|
||||
public static <T> int binarySearch(List<? extends Comparable<? super T>> list, T
|
||||
key) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1518a" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
void setup()
|
||||
{
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add("foo");
|
||||
list.add("bar");
|
||||
list.add("baz");
|
||||
|
||||
binarySearch(list, "bar");
|
||||
}
|
||||
|
||||
static <T> int binarySearch(List<? extends Comparable<? super T>> list, T
|
||||
key) {
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1518b extends PApplet {
|
||||
|
||||
|
||||
|
||||
|
||||
public void setup()
|
||||
{
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add("foo");
|
||||
list.add("bar");
|
||||
list.add("baz");
|
||||
}
|
||||
|
||||
public static <T> int binarySearch(List<? extends Comparable<? super T>> list, T
|
||||
key) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1518b" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
void setup()
|
||||
{
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add("foo");
|
||||
list.add("bar");
|
||||
list.add("baz");
|
||||
}
|
||||
|
||||
static <T> int binarySearch(List<? extends Comparable<? super T>> list, T
|
||||
key) {
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1525 extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
if (frameCount > (frameRate - 1)) {
|
||||
println("My head asplode!");
|
||||
}
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1525" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
if (frameCount > (frameRate - 1)) {
|
||||
println("My head asplode!");
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
import processing.video.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
|
||||
|
||||
final int l=50;
|
||||
final int hx=15;
|
||||
final int hy=18;
|
||||
final int dx=int((l+l*cos(PI/3))*hx);
|
||||
final int dy=int(l*sin(PI/3)*hy);
|
||||
|
||||
boolean cheatScreen=false;
|
||||
String shoot="shoot/";
|
||||
final int fr=24;
|
||||
PImage tile1,tile2;
|
||||
Capture cam;
|
||||
|
||||
|
||||
flatCube[][] grid;
|
||||
|
||||
void setup() {
|
||||
try {
|
||||
quicktime.QTSession.open();
|
||||
}
|
||||
catch (quicktime.QTException qte) {
|
||||
qte.printStackTrace();
|
||||
}
|
||||
|
||||
size (dx,dy,OPENGL);
|
||||
int d=day();
|
||||
int m=month();
|
||||
int y=year();
|
||||
int h=hour();
|
||||
int mp=minute();
|
||||
int ms=second();
|
||||
|
||||
shoot=shoot+y+m+d+h+mp+ms;
|
||||
|
||||
cam = new Capture(this, hx, hy, fr);
|
||||
frameRate(fr);
|
||||
|
||||
tile1=loadImage("111.png");
|
||||
tile2=loadImage("122.png");
|
||||
tile3=loadImage("001.png");
|
||||
grid= new flatCube[hx][hy];
|
||||
for (int j=0; j<hy;j++) {
|
||||
for (int i=0; i<hx; i++) {
|
||||
|
||||
switch ((i+j) %3 ){
|
||||
case 0: grid[i][j]= new flatCube(tile1,0) break;
|
||||
case 1: grid[i][j]= new flatCube(tile2,0); break;
|
||||
case 2: grid[i][j]= new flatCube(tile3,0); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
noStroke();
|
||||
}
|
||||
|
||||
public void captureEvent(Capture c) {
|
||||
c.read();
|
||||
}
|
||||
|
||||
|
||||
void draw() {
|
||||
|
||||
background (0,0,0);
|
||||
float x=mouseX;
|
||||
float y=mouseY;
|
||||
int signx=-1;
|
||||
int signy=-1;
|
||||
int cx=0;
|
||||
int cy=0;
|
||||
color c;
|
||||
float rot=0;
|
||||
|
||||
for (int j=0; j<hy;j++) {
|
||||
pushMatrix();
|
||||
for (int i=0; i<hx; i++) {
|
||||
c=cam.pixels[i+j*hx];
|
||||
pushMatrix();
|
||||
if (frameCount % 3 == 0 ) {
|
||||
rot=PI/3*int(random(0,7));
|
||||
cx=int (random(0,hx));
|
||||
cy=int (random(0,hy));
|
||||
}
|
||||
if ((cx==i)&&(cy==j)) grid[i][j].show(rot,c); else grid[i][j].show(c);
|
||||
popMatrix();
|
||||
translate (l+l*cos(PI/3),signx*l*sin(PI/3));
|
||||
|
||||
|
||||
signx=-signx;
|
||||
}
|
||||
popMatrix();
|
||||
signy=-signy;
|
||||
translate (signy*(l+l*cos(PI/3)),l*sin(PI/3));
|
||||
}
|
||||
|
||||
|
||||
if (cheatScreen) {
|
||||
image(cam, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void keyPressed() {
|
||||
|
||||
switch (key) {
|
||||
case 'c':
|
||||
cheatScreen = !cheatScreen;
|
||||
break;
|
||||
case 'g':
|
||||
saveFrame(shoot+"######.png");
|
||||
println ("saved "+l);
|
||||
break;
|
||||
case 'm':
|
||||
cam.settings();
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
exit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
class flatCube {
|
||||
|
||||
|
||||
PImage tile;
|
||||
float rot;
|
||||
flatCube (PImage i, float r) {
|
||||
tile=i;
|
||||
rot=r;
|
||||
}
|
||||
|
||||
void show (float r, color c){
|
||||
rot=r;
|
||||
show(c);
|
||||
}
|
||||
|
||||
void show (color c) {
|
||||
pushMatrix();
|
||||
translate(l,l*sin(PI/3));
|
||||
rotateZ(rot);
|
||||
translate(-l,-l*sin(PI/3));
|
||||
tint(c);
|
||||
image (tile,0,0);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
void show(int l,int a, color c) {
|
||||
noStroke();
|
||||
pushMatrix();
|
||||
fill(c,a);
|
||||
quad(0,0, l,0, l+l*cos(PI/3),l*sin(PI/3), l*cos(PI/3),l*sin(PI/3) );
|
||||
rotateZ(PI/3);
|
||||
fill(c,a);
|
||||
quad(0,0, l,0, l+l*cos(PI/3),l*sin(PI/3), l*cos(PI/3),l*sin(PI/3) );
|
||||
translate(l+l*cos(PI/3),l*sin(PI/3));
|
||||
rotateZ(-TWO_PI/3);
|
||||
fill (c,a);
|
||||
quad(0,0, l,0, l+l*cos(PI/3),l*sin(PI/3), l*cos(PI/3),l*sin(PI/3) );
|
||||
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1534 extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
char c = '\"';
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1534" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
char c = '\"';
|
||||
@@ -0,0 +1,9 @@
|
||||
println("Here comes an unterminated comment!");
|
||||
|
||||
/*
|
||||
banana
|
||||
apple
|
||||
pear
|
||||
* /
|
||||
|
||||
println("Do you see what I did there?");
|
||||
@@ -0,0 +1,30 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug1936 extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
char a = PApplet.parseChar(PApplet.parseByte(PApplet.parseInt("15")));
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug1936" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
char a = char(byte(int("15")));
|
||||
@@ -0,0 +1,5 @@
|
||||
int a;
|
||||
void setup()
|
||||
{
|
||||
a = #FF000;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug281 extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
if ( "monopoly".charAt( 3 ) == '(' )
|
||||
{
|
||||
println("parcheesi");
|
||||
}
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug281" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
if ( "monopoly".charAt( 3 ) == '(' )
|
||||
{
|
||||
println("parcheesi");
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug315g extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
/* size commented out by preprocessor */;
|
||||
smooth();
|
||||
int y;
|
||||
y = 60;
|
||||
int d;
|
||||
d = 80;
|
||||
ellipse(75, y, d, d);
|
||||
noLoop();
|
||||
}
|
||||
|
||||
public void settings() { size(480,120); }
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug315g" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
size(480, 120);
|
||||
smooth();
|
||||
int y;
|
||||
y = 60;
|
||||
int d;
|
||||
d = 80;
|
||||
ellipse(75, y, d, d);
|
||||
@@ -0,0 +1,35 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug4 extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
int x = 12;
|
||||
float u = (PApplet.parseFloat(x)/width);
|
||||
/* size commented out by preprocessor */;
|
||||
|
||||
noLoop();
|
||||
}
|
||||
|
||||
public void settings() { size(100,100); }
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug4" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
int x = 12;
|
||||
float u = (float(x)/width);
|
||||
size(100, /** test **/ 100);
|
||||
@@ -0,0 +1,35 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug400g extends PApplet {
|
||||
|
||||
////
|
||||
public void settings() { size(480,120); }
|
||||
|
||||
public void setup(){
|
||||
if(true){
|
||||
}
|
||||
else{ // Syntax error on token "else", } expected
|
||||
}
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug400g" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
////
|
||||
public void settings() { size(480,120); }
|
||||
|
||||
void setup(){
|
||||
if(true){
|
||||
}
|
||||
else{ // Syntax error on token "else", } expected
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
for (int i : new int[] {1, 2, 3}) {
|
||||
println(i);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
for(int i : new int[] {1,2,3}) {
|
||||
println(i);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
int[] a = new int[] { 1, 2, 3, 4, 5 };
|
||||
for (int i : a) {
|
||||
print(i);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
int[] a = new int[] { 1,2,3,4,5 };
|
||||
for (int i: a) { print(i);}
|
||||
@@ -0,0 +1,37 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug427g extends PApplet {
|
||||
|
||||
static final boolean DEBUG = true;
|
||||
|
||||
public void setup() {
|
||||
MyClass x = new MyClass();
|
||||
}
|
||||
|
||||
public class MyClass {
|
||||
public MyClass() {
|
||||
if (DEBUG) println("Debug");
|
||||
}
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug427g" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
static final boolean DEBUG = true;
|
||||
|
||||
void setup() {
|
||||
MyClass x = new MyClass();
|
||||
}
|
||||
|
||||
public class MyClass {
|
||||
public MyClass() {
|
||||
if (DEBUG) println("Debug");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.applet.Applet;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug481 extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
|
||||
Class[] abc = new Class[]{Applet.class};
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug481" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import java.applet.Applet;
|
||||
Class[] abc = new Class[]{Applet.class};
|
||||
@@ -0,0 +1,8 @@
|
||||
void setup() {
|
||||
if (1 == 2) {
|
||||
println("the impossible just happened");
|
||||
}
|
||||
} else {
|
||||
println("zzz");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.lang.Math.tanh;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.List;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug598 extends PApplet {
|
||||
|
||||
// java 5 torture test
|
||||
|
||||
private static Comparator<String> rotarapmoc = new Comparator<String>() {
|
||||
public int compare(final String o1, final String o2)
|
||||
{
|
||||
return o1.charAt(o1.length() - 1) - o2.charAt(o2.length() - 1);
|
||||
}
|
||||
};
|
||||
|
||||
public final <T> void printClass(T t) {
|
||||
println(t.getClass());
|
||||
}
|
||||
|
||||
public final List<String> sortem(final String... strings) {
|
||||
Arrays.sort(strings, rotarapmoc);
|
||||
return Arrays.asList(strings);
|
||||
}
|
||||
|
||||
final Map<String, Collection<Integer>>
|
||||
charlesDeGaulle = new HashMap<String, Collection<Integer>>();
|
||||
|
||||
public void setup() {
|
||||
charlesDeGaulle.put("banana", new HashSet<Integer>());
|
||||
charlesDeGaulle.get("banana").add(0);
|
||||
System.out.println(sortem("aztec", "maya", "spanish", "portuguese"));
|
||||
printClass(12.d);
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug598" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// java 5 torture test
|
||||
|
||||
import static java.lang.Math.tanh;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.List;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
private static Comparator<String> rotarapmoc = new Comparator<String>() {
|
||||
public int compare(final String o1, final String o2)
|
||||
{
|
||||
return o1.charAt(o1.length() - 1) - o2.charAt(o2.length() - 1);
|
||||
}
|
||||
};
|
||||
|
||||
final <T> void printClass(T t) {
|
||||
println(t.getClass());
|
||||
}
|
||||
final List<String> sortem(final String... strings) {
|
||||
Arrays.sort(strings, rotarapmoc);
|
||||
return Arrays.asList(strings);
|
||||
}
|
||||
|
||||
final Map<String, Collection<Integer>>
|
||||
charlesDeGaulle = new HashMap<String, Collection<Integer>>();
|
||||
|
||||
void setup() {
|
||||
charlesDeGaulle.put("banana", new HashSet<Integer>());
|
||||
charlesDeGaulle.get("banana").add(0);
|
||||
System.out.println(sortem("aztec", "maya", "spanish", "portuguese"));
|
||||
printClass(12.d);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug5a extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
println("The next line should not cause a failure.");
|
||||
// no newline after me
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug5a" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
println("The next line should not cause a failure.");
|
||||
// no newline after me
|
||||
@@ -0,0 +1,31 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug5b extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
println("The next line should not cause a failure.");
|
||||
/* no newline after me */
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug5b" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
println("The next line should not cause a failure.");
|
||||
/* no newline after me */
|
||||
@@ -0,0 +1 @@
|
||||
println("hello");/println("world");
|
||||
@@ -0,0 +1,36 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class bug631 extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
firstLoop:
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int j = 0; j < 10; j++) {
|
||||
if ((i+j) % 5 != 0) continue firstLoop;
|
||||
System.out.println(i + " " + j);
|
||||
}
|
||||
}
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "bug631" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
firstLoop:
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int j = 0; j < 10; j++) {
|
||||
if ((i+j) % 5 != 0) continue firstLoop;
|
||||
System.out.println(i + " " + j);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
println("i am a bug...);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
float x1 = 0;
|
||||
float x1 = 2;
|
||||
@@ -0,0 +1,32 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class charspecial extends PApplet {
|
||||
|
||||
public void setup() {
|
||||
char x = '\n';
|
||||
println(x);
|
||||
|
||||
noLoop();
|
||||
}
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "charspecial" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user