From 9ea128cc21eb61c0f2ddc7b4ce290c36f5e2f006 Mon Sep 17 00:00:00 2001 From: A Samuel Pottinger Date: Sat, 12 Nov 2022 17:29:20 +0000 Subject: [PATCH] Add failing test for static mode class defintion. --- .../processing/mode/java/ParserTests.java | 5 ++ java/test/resources/staticclass.expected | 47 +++++++++++++++++++ java/test/resources/staticclass.pde | 19 ++++++++ 3 files changed, 71 insertions(+) create mode 100644 java/test/resources/staticclass.expected create mode 100644 java/test/resources/staticclass.pde diff --git a/java/test/processing/mode/java/ParserTests.java b/java/test/processing/mode/java/ParserTests.java index 8142b5443..c38a2b820 100644 --- a/java/test/processing/mode/java/ParserTests.java +++ b/java/test/processing/mode/java/ParserTests.java @@ -443,4 +443,9 @@ public class ParserTests { expectGood("fullscreen_export"); } + @Test + public void testStaticClass() { + expectGood("staticclass"); + } + } diff --git a/java/test/resources/staticclass.expected b/java/test/resources/staticclass.expected new file mode 100644 index 000000000..e2a67d90c --- /dev/null +++ b/java/test/resources/staticclass.expected @@ -0,0 +1,47 @@ +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 staticclass extends PApplet { + public void setup() { +class Button { + + int x, y, radius; + + public Button (int x, int y, int radius) { + this.x = x; + this.y = y; + this.radius = radius; + } + + public boolean over() { + return dist(mouseX, mouseY, this.x, this.y) < this.radius; + } + + public void draw() { + ellipse(this.x, this.y, this.radius * 2, this.radius * 2); + } + +} + noLoop(); + } + + static public void main(String[] passedArgs) { + String[] appletArgs = new String[] { "staticclass" }; + if (passedArgs != null) { + PApplet.main(concat(appletArgs, passedArgs)); + } else { + PApplet.main(appletArgs); + } + } +} \ No newline at end of file diff --git a/java/test/resources/staticclass.pde b/java/test/resources/staticclass.pde new file mode 100644 index 000000000..b2bf6ddcb --- /dev/null +++ b/java/test/resources/staticclass.pde @@ -0,0 +1,19 @@ +class Button { + + int x, y, radius; + + public Button (int x, int y, int radius) { + this.x = x; + this.y = y; + this.radius = radius; + } + + boolean over() { + return dist(mouseX, mouseY, this.x, this.y) < this.radius; + } + + void draw() { + ellipse(this.x, this.y, this.radius * 2, this.radius * 2); + } + +}