Copilot commented on code in PR #6136:
URL: https://github.com/apache/texera/pull/6136#discussion_r3524362299


##########
common/pybuilder/src/test/scala/org/apache/texera/amber/pybuilder/PythonLexerUtilsSpec.scala:
##########
@@ -131,6 +131,25 @@ class PythonLexerUtilsSpec extends AnyFunSuite {
     assert(state.isEmpty)
   }
 
+  test(
+    "updateTripleQuotedStringState: an escaped quote inside an ordinary string 
is not a boundary"
+  ) {
+    // Python:  x = "a\"b"  — the escaped " must not close the double-quoted 
string
+    assert(PythonLexerUtils.updateTripleQuotedStringState("x = \"a\\\"b\"", 
None).isEmpty)
+    // Python:  y = 'a\'b'  — same for a single-quoted string
+    assert(PythonLexerUtils.updateTripleQuotedStringState("y = 'a\\'b'", 
None).isEmpty)
+  }
+
+  test("updateTripleQuotedStringState: a lone single-quoted string toggles 
single-quote mode") {
+    // Python:  name = 'abc'  — opens then closes single-quote mode, leaving 
no active delimiter
+    assert(PythonLexerUtils.updateTripleQuotedStringState("name = 'abc'", 
None).isEmpty)
+  }

Review Comment:
   This assertion can pass even if single-quote mode never toggles, because the 
expected output is `None` either way. To make the test validate the intended 
behavior (and catch regressions), use an input where handling of a 
single-quoted string affects whether a later triple-quote delimiter is detected 
(e.g., a `#` inside the single-quoted string followed by `'''`).



##########
common/pybuilder/src/test/scala/org/apache/texera/amber/pybuilder/PythonLexerUtilsSpec.scala:
##########
@@ -131,6 +131,25 @@ class PythonLexerUtilsSpec extends AnyFunSuite {
     assert(state.isEmpty)
   }
 
+  test(
+    "updateTripleQuotedStringState: an escaped quote inside an ordinary string 
is not a boundary"
+  ) {
+    // Python:  x = "a\"b"  — the escaped " must not close the double-quoted 
string
+    assert(PythonLexerUtils.updateTripleQuotedStringState("x = \"a\\\"b\"", 
None).isEmpty)
+    // Python:  y = 'a\'b'  — same for a single-quoted string
+    assert(PythonLexerUtils.updateTripleQuotedStringState("y = 'a\\'b'", 
None).isEmpty)
+  }
+
+  test("updateTripleQuotedStringState: a lone single-quoted string toggles 
single-quote mode") {
+    // Python:  name = 'abc'  — opens then closes single-quote mode, leaving 
no active delimiter
+    assert(PythonLexerUtils.updateTripleQuotedStringState("name = 'abc'", 
None).isEmpty)
+  }
+
+  test("updateTripleQuotedStringState: a hash inside a double-quoted string is 
not a comment") {
+    // Python:  s = "a # b" + c  — the # is inside the string, so scanning 
must not early-return
+    assert(PythonLexerUtils.updateTripleQuotedStringState("s = \"a # b\" + c", 
None).isEmpty)
+  }

Review Comment:
   This test intends to ensure `#` inside a double-quoted string is not treated 
as a comment, but `updateTripleQuotedStringState(..., None)` returns `None` 
even if it incorrectly early-returns at `#`. Consider appending a triple-quote 
delimiter after the ordinary string so that an incorrect comment-early-return 
would change the result (should return `Some("\"\"\"")`).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to