From bf15f0e299d9bfae1994d486995cb8b5f953e49f Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sat, 30 Nov 2024 19:26:11 +0100 Subject: [PATCH] js: support writing debugger statement in JSBody Fix #974 --- .../org/teavm/backend/javascript/rendering/AstWriter.java | 3 +++ .../teavm/backend/javascript/rendering/AstWriterTest.java | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/core/src/main/java/org/teavm/backend/javascript/rendering/AstWriter.java b/core/src/main/java/org/teavm/backend/javascript/rendering/AstWriter.java index 3399e4022..3661a4131 100644 --- a/core/src/main/java/org/teavm/backend/javascript/rendering/AstWriter.java +++ b/core/src/main/java/org/teavm/backend/javascript/rendering/AstWriter.java @@ -291,6 +291,9 @@ public class AstWriter { case Token.WHILE: print((WhileLoop) node); break; + case Token.DEBUGGER: + writer.append("debugger;"); + break; default: if (node instanceof InfixExpression) { printInfix((InfixExpression) node, precedence); diff --git a/core/src/test/java/org/teavm/backend/javascript/rendering/AstWriterTest.java b/core/src/test/java/org/teavm/backend/javascript/rendering/AstWriterTest.java index f163b9b95..ab9779020 100644 --- a/core/src/test/java/org/teavm/backend/javascript/rendering/AstWriterTest.java +++ b/core/src/test/java/org/teavm/backend/javascript/rendering/AstWriterTest.java @@ -255,6 +255,11 @@ public class AstWriterTest { assertEquals("delete a.b;", transform("delete a.b;")); } + @Test + public void writesDebugger() throws IOException { + assertEquals("debugger;debugger;", transform("debugger; debugger;")); + } + @Test public void writesGlobalRef() throws IOException { assertEquals(