mirror of
https://github.com/processing/processing4.git
synced 2026-04-19 02:39:23 +02:00
Detect if calling special methods on the PApplet or not.
This commit is contained in:
@@ -375,6 +375,11 @@ public class ParserTests {
|
||||
expectGood("smoothnoparam");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSmoothThis() {
|
||||
expectGood("smoothnoparamthis");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSmoothWithParam() {
|
||||
expectGood("smoothparam");
|
||||
@@ -390,9 +395,14 @@ public class ParserTests {
|
||||
expectGood("colorimport");
|
||||
}
|
||||
|
||||
/*@Test
|
||||
@Test
|
||||
public void testPGraphicsStandalone() {
|
||||
expectGood("pgraphics");
|
||||
}*/
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSizeThis() {
|
||||
expectGood("sizethis");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 pgraphics extends PApplet {
|
||||
|
||||
PGraphics gfx;
|
||||
|
||||
public void setup() {
|
||||
|
||||
gfx = createGraphics(width, height);
|
||||
gfx.smooth();
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
}
|
||||
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "pgraphics" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
45
java/test/resources/sizethis.expected
Normal file
45
java/test/resources/sizethis.expected
Normal file
@@ -0,0 +1,45 @@
|
||||
import processing.core.*;
|
||||
import processing.data.*;
|
||||
import processing.event.*;
|
||||
import processing.opengl.*;
|
||||
|
||||
import processing.pdf.*;
|
||||
|
||||
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 sizethis extends PApplet {
|
||||
|
||||
|
||||
|
||||
public void setup() {
|
||||
/* size commented out by preprocessor */;
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
// Draw something good here
|
||||
line(0, 0, width/2, height);
|
||||
|
||||
// Exit the program
|
||||
println("Finished.");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
public void settings() { size(400,400,PDF,"filename.pdf"); }
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "sizethis" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
14
java/test/resources/sizethis.pde
Normal file
14
java/test/resources/sizethis.pde
Normal file
@@ -0,0 +1,14 @@
|
||||
import processing.pdf.*;
|
||||
|
||||
void setup() {
|
||||
this.size(400, 400, PDF, "filename.pdf");
|
||||
}
|
||||
|
||||
void draw() {
|
||||
// Draw something good here
|
||||
line(0, 0, width/2, height);
|
||||
|
||||
// Exit the program
|
||||
println("Finished.");
|
||||
exit();
|
||||
}
|
||||
42
java/test/resources/smoothnoparamthis.expected
Normal file
42
java/test/resources/smoothnoparamthis.expected
Normal file
@@ -0,0 +1,42 @@
|
||||
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 smoothnoparamthis extends PApplet {
|
||||
|
||||
public void setup(){
|
||||
/* size commented out by preprocessor */;
|
||||
/* smooth commented out by preprocessor */;
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
background(0);
|
||||
fill(255,0,0);
|
||||
ellipse(100,100,100,100);
|
||||
fill(0,255,0);
|
||||
ellipse(150,150,100,100);
|
||||
}
|
||||
|
||||
|
||||
public void settings() { size(300, 300, P2D);
|
||||
smooth(); }
|
||||
|
||||
static public void main(String[] passedArgs) {
|
||||
String[] appletArgs = new String[] { "smoothnoparamthis" };
|
||||
if (passedArgs != null) {
|
||||
PApplet.main(concat(appletArgs, passedArgs));
|
||||
} else {
|
||||
PApplet.main(appletArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
java/test/resources/smoothnoparamthis.pde
Normal file
12
java/test/resources/smoothnoparamthis.pde
Normal file
@@ -0,0 +1,12 @@
|
||||
void setup(){
|
||||
size(300,300, P2D);
|
||||
this.smooth();
|
||||
}
|
||||
|
||||
void draw(){
|
||||
background(0);
|
||||
fill(255,0,0);
|
||||
ellipse(100,100,100,100);
|
||||
fill(0,255,0);
|
||||
ellipse(150,150,100,100);
|
||||
}
|
||||
Reference in New Issue
Block a user