This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 4a6536f57057d59b625c349057a9cc64ef7bf2fa
Author: Josh Tynjala <[email protected]>
AuthorDate: Tue Nov 29 12:43:21 2022 -0800

    Tests: more nullish coalescing operator tests
---
 .../java/as/ASNullishCoalescingOperatorTests.java  | 56 ++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/compiler/src/test/java/as/ASNullishCoalescingOperatorTests.java 
b/compiler/src/test/java/as/ASNullishCoalescingOperatorTests.java
index a58d777b1..5e593120d 100644
--- a/compiler/src/test/java/as/ASNullishCoalescingOperatorTests.java
+++ b/compiler/src/test/java/as/ASNullishCoalescingOperatorTests.java
@@ -81,4 +81,60 @@ public class ASNullishCoalescingOperatorTests extends 
ASFeatureTestsBase
 
         compileAndRun(source);
     }
+
+    @Test
+    public void testUnparenthesizedLogicalAndBefore()
+    {
+        String[] testCode = new String[]
+        {
+            "var bool:Boolean = true",
+            "var s:String = 'foo';",
+                       "var result:Object = bool && s ?? 'bar';",
+        };
+        String source = getAS(new String[0], new String[0], testCode, new 
String[0]);
+
+        compileAndExpectErrors(source, false, false, false, new String[0], 
"Cannot use '??' unparenthesized within '||' and '&&' expressions.\n");
+    }
+
+    @Test
+    public void testUnparenthesizedLogicalAndAfter()
+    {
+        String[] testCode = new String[]
+        {
+            "var bool:Boolean = true",
+            "var s:String = 'foo';",
+                       "var result:Object = s ?? 'bar' && bool;",
+        };
+        String source = getAS(new String[0], new String[0], testCode, new 
String[0]);
+
+        compileAndExpectErrors(source, false, false, false, new String[0], 
"Cannot use '??' unparenthesized within '||' and '&&' expressions.\n");
+    }
+
+    @Test
+    public void testUnparenthesizedLogicalOrBefore()
+    {
+        String[] testCode = new String[]
+        {
+            "var bool:Boolean = false",
+            "var s:String = 'foo';",
+                       "var result:Object = bool || s ?? 'bar';",
+        };
+        String source = getAS(new String[0], new String[0], testCode, new 
String[0]);
+
+        compileAndExpectErrors(source, false, false, false, new String[0], 
"Cannot use '??' unparenthesized within '||' and '&&' expressions.\n");
+    }
+
+    @Test
+    public void testUnparenthesizedLogicalOrAfter()
+    {
+        String[] testCode = new String[]
+        {
+            "var bool:Boolean = false",
+            "var s:String = 'foo';",
+                       "var result:Object = s ?? 'bar' || bool;",
+        };
+        String source = getAS(new String[0], new String[0], testCode, new 
String[0]);
+
+        compileAndExpectErrors(source, false, false, false, new String[0], 
"Cannot use '??' unparenthesized within '||' and '&&' expressions.\n");
+    }
 }

Reply via email to