From ff4cfd575a9b731adc60582de447fafb5303eb49 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Tue, 11 Feb 2014 13:53:32 -0800 Subject: SI-8266 Deprecate octal escapes in f-interpolator Also turns the f-interpolator into a migration assistant by suggesting alternatives for the standard escapes. --- test/files/neg/t8266-invalid-interp.check | 10 ++++++++++ test/files/neg/t8266-invalid-interp.scala | 9 +++++++++ test/files/run/t8266-octal-interp.check | 30 ++++++++++++++++++++++++++++++ test/files/run/t8266-octal-interp.flags | 1 + test/files/run/t8266-octal-interp.scala | 16 ++++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 test/files/neg/t8266-invalid-interp.check create mode 100644 test/files/neg/t8266-invalid-interp.scala create mode 100644 test/files/run/t8266-octal-interp.check create mode 100644 test/files/run/t8266-octal-interp.flags create mode 100644 test/files/run/t8266-octal-interp.scala (limited to 'test/files') diff --git a/test/files/neg/t8266-invalid-interp.check b/test/files/neg/t8266-invalid-interp.check new file mode 100644 index 0000000000..70dd4081b0 --- /dev/null +++ b/test/files/neg/t8266-invalid-interp.check @@ -0,0 +1,10 @@ +t8266-invalid-interp.scala:4: error: Trailing '\' escapes nothing. + f"a\", + ^ +t8266-invalid-interp.scala:5: error: invalid escape character at index 1 in "a\xc" + f"a\xc", + ^ +t8266-invalid-interp.scala:7: error: invalid escape character at index 1 in "a\vc" + f"a\vc" + ^ +three errors found diff --git a/test/files/neg/t8266-invalid-interp.scala b/test/files/neg/t8266-invalid-interp.scala new file mode 100644 index 0000000000..4b26546880 --- /dev/null +++ b/test/files/neg/t8266-invalid-interp.scala @@ -0,0 +1,9 @@ + +trait X { + def f = Seq( + f"a\", + f"a\xc", + // following could suggest \u000b for vertical tab, similar for \a alert + f"a\vc" + ) +} diff --git a/test/files/run/t8266-octal-interp.check b/test/files/run/t8266-octal-interp.check new file mode 100644 index 0000000000..6e9454119b --- /dev/null +++ b/test/files/run/t8266-octal-interp.check @@ -0,0 +1,30 @@ +t8266-octal-interp.scala:4: warning: Octal escape literals are deprecated, use \b instead. + f"a\10c", + ^ +t8266-octal-interp.scala:5: warning: Octal escape literals are deprecated, use \t instead. + f"a\11c", + ^ +t8266-octal-interp.scala:6: warning: Octal escape literals are deprecated, use \n instead. + f"a\12c", + ^ +t8266-octal-interp.scala:7: warning: Octal escape literals are deprecated, use \r instead. + f"a\15c", + ^ +t8266-octal-interp.scala:8: warning: Octal escape literals are deprecated, use \u0022 instead. + f"a\42c", + ^ +t8266-octal-interp.scala:9: warning: Octal escape literals are deprecated, use \\ instead. + f"a\134c", + ^ +t8266-octal-interp.scala:10: warning: Octal escape literals are deprecated, use \u0069 instead. + f"a\15151515c" + ^ +ac +a c +a +c +a +c +a"c +a\c +ai51515c diff --git a/test/files/run/t8266-octal-interp.flags b/test/files/run/t8266-octal-interp.flags new file mode 100644 index 0000000000..dcc59ebe32 --- /dev/null +++ b/test/files/run/t8266-octal-interp.flags @@ -0,0 +1 @@ +-deprecation diff --git a/test/files/run/t8266-octal-interp.scala b/test/files/run/t8266-octal-interp.scala new file mode 100644 index 0000000000..f85ae0367d --- /dev/null +++ b/test/files/run/t8266-octal-interp.scala @@ -0,0 +1,16 @@ + +trait X { + def f = Seq( + f"a\10c", + f"a\11c", + f"a\12c", + f"a\15c", + f"a\42c", + f"a\134c", + f"a\15151515c" + ) +} + +object Test extends App with X { + f foreach println +} -- cgit v1.2.3