mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 21:59:20 +01:00
Preprocessor Enum test
This commit is contained in:
56
app/test/resources/bug1390.expected
Normal file
56
app/test/resources/bug1390.expected
Normal file
@@ -0,0 +1,56 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/test/resources/bug1390.pde
Normal file
29
app/test/resources/bug1390.pde
Normal file
@@ -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);
|
||||
}
|
||||
@@ -201,6 +201,11 @@ public class ParserTests {
|
||||
public void bug1362() {
|
||||
expectGood("bug1362");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1390() {
|
||||
expectGood("bug1390");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug1442() {
|
||||
|
||||
Reference in New Issue
Block a user