From 5626c7403e44380c6e3610cae8f68f3d2b52eb70 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 30 Jul 2013 11:37:59 +0200 Subject: [nomaster] macro errors now always have positions Back then when I implemented macros for inclusion in trunk (Spring 2012), partest didn't support the _1, _2, ... convention for neg tests, so I had to use toolboxes to test macro-generated exceptions. Unfortunately toolboxes aren't very good with positions (mostly because their inputs are almost always constructed without corresponding sources) so I didn't notice that errors signalizing about macro-generated exceptions actually don't carry positions with them because of a typo. This patch fixes the oversight, but it doesn't need to be ported to master, because over there everything's already fixed by one of the backports from macro paradise. --- test/files/neg/macro-abort.check | 4 ++++ test/files/neg/macro-abort/Macros_1.scala | 9 +++++++++ test/files/neg/macro-abort/Test_2.scala | 3 +++ test/files/neg/macro-exception.check | 7 +++++++ test/files/neg/macro-exception/Macros_1.scala | 9 +++++++++ test/files/neg/macro-exception/Test_2.scala | 3 +++ 6 files changed, 35 insertions(+) create mode 100644 test/files/neg/macro-abort.check create mode 100644 test/files/neg/macro-abort/Macros_1.scala create mode 100644 test/files/neg/macro-abort/Test_2.scala create mode 100644 test/files/neg/macro-exception.check create mode 100644 test/files/neg/macro-exception/Macros_1.scala create mode 100644 test/files/neg/macro-exception/Test_2.scala (limited to 'test/files') diff --git a/test/files/neg/macro-abort.check b/test/files/neg/macro-abort.check new file mode 100644 index 0000000000..1e58add533 --- /dev/null +++ b/test/files/neg/macro-abort.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: aborted + Macros.abort + ^ +one error found diff --git a/test/files/neg/macro-abort/Macros_1.scala b/test/files/neg/macro-abort/Macros_1.scala new file mode 100644 index 0000000000..676c112098 --- /dev/null +++ b/test/files/neg/macro-abort/Macros_1.scala @@ -0,0 +1,9 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + def impl(c: Context) = { + c.abort(c.enclosingPosition, "aborted") + } + def abort = macro impl +} \ No newline at end of file diff --git a/test/files/neg/macro-abort/Test_2.scala b/test/files/neg/macro-abort/Test_2.scala new file mode 100644 index 0000000000..1d0a7a25dc --- /dev/null +++ b/test/files/neg/macro-abort/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.abort +} \ No newline at end of file diff --git a/test/files/neg/macro-exception.check b/test/files/neg/macro-exception.check new file mode 100644 index 0000000000..cee8b32ebd --- /dev/null +++ b/test/files/neg/macro-exception.check @@ -0,0 +1,7 @@ +Test_2.scala:2: error: exception during macro expansion: +java.lang.Exception + at Macros$.impl(Macros_1.scala:6) + + Macros.exception + ^ +one error found diff --git a/test/files/neg/macro-exception/Macros_1.scala b/test/files/neg/macro-exception/Macros_1.scala new file mode 100644 index 0000000000..60e4020aec --- /dev/null +++ b/test/files/neg/macro-exception/Macros_1.scala @@ -0,0 +1,9 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + def impl(c: Context) = { + throw new Exception() + } + def exception = macro impl +} \ No newline at end of file diff --git a/test/files/neg/macro-exception/Test_2.scala b/test/files/neg/macro-exception/Test_2.scala new file mode 100644 index 0000000000..d82b21f2b2 --- /dev/null +++ b/test/files/neg/macro-exception/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.exception +} \ No newline at end of file -- cgit v1.2.3