Fix size call with equation.

This commit is contained in:
A Samuel Pottinger
2022-11-27 19:04:56 +00:00
parent 1ca265aa43
commit 54426cb8a7
6 changed files with 167 additions and 8 deletions
@@ -50,6 +50,22 @@ public class ParserTests {
}
}
static void expectRunnerException(final String id) {
try {
preprocess(id, res(id + ".pde"));
fail("Expected to fail");
} catch (SketchException e) {
assertNotNull(e);
} catch (PdePreprocessIssueException e) {
assertNotNull(e.getIssue().getMsg());
} 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) {
@@ -453,4 +469,19 @@ public class ParserTests {
expectGood("customrootclass");
}
@Test
public void testExpessionSize() {
expectGood("expressionsize");
}
@Test
public void testExpessionSizeMethod() {
expectRunnerException("expressionsizemethod");
}
@Test
public void testExpessionSizeVar() {
expectRunnerException("expressionsizevar");
}
}
@@ -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 expressionsize 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*2,4e2/2); }
static public void main(String[] passedArgs) {
String[] appletArgs = new String[] { "expressionsize" };
if (passedArgs != null) {
PApplet.main(concat(appletArgs, passedArgs));
} else {
PApplet.main(appletArgs);
}
}
}
+14
View File
@@ -0,0 +1,14 @@
import processing.pdf.*;
void setup() {
size(400*2, 4e2/2);
}
void draw() {
// Draw something good here
line(0, 0, width/2, height);
// Exit the program
println("Finished.");
exit();
}
@@ -0,0 +1,18 @@
import processing.pdf.*;
int getWidth() {
return 400*2;
}
void setup() {
size(getWidth(), 400/2);
}
void draw() {
// Draw something good here
line(0, 0, width/2, height);
// Exit the program
println("Finished.");
exit();
}
+19
View File
@@ -0,0 +1,19 @@
import processing.pdf.*;
int getWidth() {
return 400*2;
}
void setup() {
int newWidth = 400*2;
size(newWidth, 400/2);
}
void draw() {
// Draw something good here
line(0, 0, width/2, height);
// Exit the program
println("Finished.");
exit();
}