Skip to content

Commit

Permalink
Closes #317: Preproc behavior when size defined in user class.
Browse files Browse the repository at this point in the history
Though this was already fixed, just adding a test to confirm that it stays fixed. Need to respect calls to user-definined size methods including those defined in user-made classes.
  • Loading branch information
sampottinger committed Jan 29, 2022
1 parent c7d6cba commit 30cee88
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
5 changes: 5 additions & 0 deletions java/test/processing/mode/java/ParserTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,9 @@ public void testMixing() {
expectRunnerException("mixing", 1);
}

@Test
public void testSizeClass() {
expectGood("sizeclass");
}

}
50 changes: 50 additions & 0 deletions java/test/resources/sizeclass.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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 sizeclass extends PApplet {

// Thanks StanLepunK: https://github.com/processing/processing4/issues/317
Truc truc = new Truc();

public void setup() {
/* size commented out by preprocessor */;
truc.size(1,1); // problem >>> error \u00e0 "."
// func();
}

public void draw() {
truc.size(1,1); // no problem
}

public void func() {
truc.size(1,1); // no problem
}

class Truc {
public void size(int x, int y) {
}
}


public void settings() { size(200, 200); }

static public void main(String[] passedArgs) {
String[] appletArgs = new String[] { "sizeclass" };
if (passedArgs != null) {
PApplet.main(concat(appletArgs, passedArgs));
} else {
PApplet.main(appletArgs);
}
}
}
21 changes: 21 additions & 0 deletions java/test/resources/sizeclass.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Thanks StanLepunK: https://github.com/processing/processing4/issues/317
Truc truc = new Truc();

void setup() {
size(200,200);
truc.size(1,1); // problem >>> error à "."
// func();
}

void draw() {
truc.size(1,1); // no problem
}

void func() {
truc.size(1,1); // no problem
}

class Truc {
void size(int x, int y) {
}
}

0 comments on commit 30cee88

Please sign in to comment.