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

jinterrante pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil.git


The following commit(s) were added to refs/heads/main by this push:
     new 9dd5b006e Update scalafmt-core to 3.7.17
9dd5b006e is described below

commit 9dd5b006ef1ddf129f94e019a63db033863fe6e5
Author: Scala Steward <[email protected]>
AuthorDate: Fri Nov 17 10:05:52 2023 -0500

    Update scalafmt-core to 3.7.17
    
    - Also changes how we use invalid surrogate pairs in string literals in
      tests. Scalafmt detects them so we must create invalid surrogate pairs
      manually.
---
 .scalafmt.conf                                     |  2 +-
 .../apache/daffodil/lib/util/TestPUARemapper.scala | 32 ++++++++++++++++++----
 .../runtime1/parser/TestCharsetBehavior.scala      |  6 ++--
 3 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/.scalafmt.conf b/.scalafmt.conf
index 78147e4f5..d0200904a 100644
--- a/.scalafmt.conf
+++ b/.scalafmt.conf
@@ -32,4 +32,4 @@ rewrite.rules = [
 rewrite.trailingCommas.style = always
 runner.dialect = scala212
 spaces.inImportCurlyBraces = true
-version = 3.7.14
+version = 3.7.17
diff --git 
a/daffodil-lib/src/test/scala/org/apache/daffodil/lib/util/TestPUARemapper.scala
 
b/daffodil-lib/src/test/scala/org/apache/daffodil/lib/util/TestPUARemapper.scala
index 2131b7168..5e8daf74c 100644
--- 
a/daffodil-lib/src/test/scala/org/apache/daffodil/lib/util/TestPUARemapper.scala
+++ 
b/daffodil-lib/src/test/scala/org/apache/daffodil/lib/util/TestPUARemapper.scala
@@ -76,7 +76,10 @@ class TestPUARemapper {
   @Test def testRemapXMLIllegalCharToPUA(): Unit = {
     val ec = xmlToPUANoCR2LF.remap("\u0000")
     assertEquals("\uE000", ec)
-    val ed = xmlToPUANoCR2LF.remap("\uD880")
+    // scalafmt detects invalid surrogate pairs in unicode literals, so we 
can't use them like
+    // we do for other tests--we must manually create the surrogate chars and 
append to a string
+    val loneSurrogate = 0xd880.toChar
+    val ed = xmlToPUANoCR2LF.remap("" + loneSurrogate)
     assertEquals("\uE880", ed)
     val crInPUA = xmlToPUANoCR2LF.remap("\u000d") // CR
     assertEquals("\uE00D", crInPUA)
@@ -93,13 +96,22 @@ class TestPUARemapper {
   @Test def testRemapXMLSurrogateCharactersToPUA(): Unit = {
     assertEquals(2, elephant.length)
     assertEquals("\uD80C\uDCF0", elephant)
-    val input = "elephant" + elephant + "isolatedHigh\uD80CisolatedLow\uDCF0"
+    // scalafmt detects invalid surrogate pairs in unicode literals, so we 
can't use them like
+    // we do for other tests--we must manually create the surrogate chars and 
append to a string
+    val highSurrogate = 0xd80c.toChar
+    val lowSurrogate = 0xdcf0.toChar
+    val input =
+      "elephant" + elephant + "isolatedHigh" + highSurrogate + "isolatedLow" + 
lowSurrogate
     val actual = xmlToPUANoCR2LF.remap(input)
     assertEquals("elephant\uD80C\uDCF0isolatedHigh\uE80CisolatedLow\uECF0", 
actual)
   }
 
   @Test def testRemapXMLSurrogateCharactersToPUA2(): Unit = {
-    val input = "badSurrogateOrder lowFirst\uDCF0\uD80CthenHigh"
+    // scalafmt detects invalid surrogate pairs in unicode literals, so we 
can't use them like
+    // we do for other tests--we must manually create the surrogate chars and 
append to a string
+    val highSurrogate = 0xd80c.toChar
+    val lowSurrogate = 0xdcf0.toChar
+    val input = "badSurrogateOrder lowFirst" + lowSurrogate + highSurrogate + 
"thenHigh"
     val actual = xmlToPUANoCR2LF.remap(input)
     assertEquals("badSurrogateOrder lowFirst\uECF0\uE80CthenHigh", actual)
   }
@@ -132,7 +144,10 @@ class TestRemapPUAToXML() {
     val ec = puaToXML.remap("\uE000")
     assertEquals("\u0000", ec)
     val ed = puaToXML.remap("\uE880")
-    assertEquals("\uD880", ed)
+    // scalafmt detects invalid surrogate pairs in unicode literals, so we 
can't use them like
+    // we do for other tests--we must manually create the surrogate chars and 
append to a string
+    val loneSurrogate = 0xd880.toChar
+    assertEquals("" + loneSurrogate, ed)
     val cr = puaToXML.remap("\uE00D")
     assertEquals("\u000D", cr)
   }
@@ -144,9 +159,16 @@ class TestRemapPUAToXML() {
   }
 
   @Test def testRemapPUAToSurrogateChars(): Unit = {
+    // scalafmt detects invalid surrogate pairs in unicode literals, so we 
can't use them like
+    // we do for other tests--we must manually create the surrogate chars and 
append to a string
+    val highSurrogate = 0xd80c.toChar
+    val lowSurrogate = 0xdcf0.toChar
     val input = "elephant\uD80C\uDCF0isolatedHigh\uE80CisolatedLow\uECF0"
     val actual = puaToXML.remap(input)
-    assertEquals("elephant" + elephant + 
"isolatedHigh\uD80CisolatedLow\uDCF0", actual)
+    assertEquals(
+      "elephant" + elephant + "isolatedHigh" + highSurrogate + "isolatedLow" + 
lowSurrogate,
+      actual,
+    )
   }
 
 }
diff --git 
a/daffodil-runtime1/src/test/scala/org/apache/daffodil/runtime1/parser/TestCharsetBehavior.scala
 
b/daffodil-runtime1/src/test/scala/org/apache/daffodil/runtime1/parser/TestCharsetBehavior.scala
index 0d09e6a5f..d26147534 100644
--- 
a/daffodil-runtime1/src/test/scala/org/apache/daffodil/runtime1/parser/TestCharsetBehavior.scala
+++ 
b/daffodil-runtime1/src/test/scala/org/apache/daffodil/runtime1/parser/TestCharsetBehavior.scala
@@ -154,8 +154,10 @@ class TestUnicodeErrorTolerance {
    * is presented to the encoder.
    */
   @Test def testUTF8Encode3ByteSurrogateReplacement(): Unit = {
-    val s = "\ud800"
-    val act = replaceBadCharactersEncoding(s)
+    // scalafmt detects invalid surrogate pairs in unicode literals, so we 
can't use them like
+    // we do for other tests--we must manually create the surrogate chars and 
append to a string
+    val s = 0xd800.toChar
+    val act = replaceBadCharactersEncoding("" + s)
     val exp = Array[Int](0xef, 0xbf, 0xbd) // the 3-byte UTF-8 replacement 
sequence
     // which is just the UTF-8 encoding of the Unicode replacement character 
U+FFFD.
     for ((e, a) <- exp.zip(act)) {

Reply via email to