From c09481eb8e1475c9495c6d5a59df7234803b2a95 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 16 Jul 2012 20:56:35 +0200 Subject: Added tests for @ExtensionMethod --- .../after-delombok/ExtensionMethodPlain.java | 17 +++++++++++++++ .../resource/after-ecj/ExtensionMethodPlain.java | 25 ++++++++++++++++++++++ .../resource/before/ExtensionMethodPlain.java | 23 ++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 test/transform/resource/after-delombok/ExtensionMethodPlain.java create mode 100644 test/transform/resource/after-ecj/ExtensionMethodPlain.java create mode 100644 test/transform/resource/before/ExtensionMethodPlain.java (limited to 'test/transform') diff --git a/test/transform/resource/after-delombok/ExtensionMethodPlain.java b/test/transform/resource/after-delombok/ExtensionMethodPlain.java new file mode 100644 index 00000000..707a0258 --- /dev/null +++ b/test/transform/resource/after-delombok/ExtensionMethodPlain.java @@ -0,0 +1,17 @@ +class ExtensionMethodPlain { + public String test() { + int[] intArray = {5, 3, 8, 2}; + java.util.Arrays.sort(intArray); + String iAmNull = null; + return ExtensionMethodPlain.Extensions.or(iAmNull, ExtensionMethodPlain.Extensions.toTitleCase("hELlO, WORlD!")); + } + static class Extensions { + public static T or(T obj, T ifNull) { + return obj != null ? obj : ifNull; + } + public static String toTitleCase(String in) { + if (in.isEmpty()) return in; + return "" + Character.toTitleCase(in.charAt(0)) + in.substring(1).toLowerCase(); + } + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/ExtensionMethodPlain.java b/test/transform/resource/after-ecj/ExtensionMethodPlain.java new file mode 100644 index 00000000..6e719853 --- /dev/null +++ b/test/transform/resource/after-ecj/ExtensionMethodPlain.java @@ -0,0 +1,25 @@ +import lombok.experimental.ExtensionMethod; +@ExtensionMethod({java.util.Arrays.class, ExtensionMethodPlain.Extensions.class}) class ExtensionMethodPlain { + static class Extensions { + Extensions() { + super(); + } + public static T or(T obj, T ifNull) { + return ((obj != null) ? obj : ifNull); + } + public static String toTitleCase(String in) { + if (in.isEmpty()) + return in; + return (("" + Character.toTitleCase(in.charAt(0))) + in.substring(1).toLowerCase()); + } + } + ExtensionMethodPlain() { + super(); + } + public String test() { + int[] intArray = {5, 3, 8, 2}; + java.util.Arrays.sort(intArray); + String iAmNull = null; + return ExtensionMethodPlain.Extensions.or(iAmNull, ExtensionMethodPlain.Extensions.toTitleCase("hELlO, WORlD!")); + } +} \ No newline at end of file diff --git a/test/transform/resource/before/ExtensionMethodPlain.java b/test/transform/resource/before/ExtensionMethodPlain.java new file mode 100644 index 00000000..8c2f369d --- /dev/null +++ b/test/transform/resource/before/ExtensionMethodPlain.java @@ -0,0 +1,23 @@ +import lombok.experimental.ExtensionMethod; + +@ExtensionMethod({java.util.Arrays.class, ExtensionMethodPlain.Extensions.class}) +class ExtensionMethodPlain { + public String test() { + int[] intArray = {5, 3, 8, 2}; + intArray.sort(); + + String iAmNull = null; + return iAmNull.or("hELlO, WORlD!".toTitleCase()); + } + + static class Extensions { + public static T or(T obj, T ifNull) { + return obj != null ? obj : ifNull; + } + + public static String toTitleCase(String in) { + if (in.isEmpty()) return in; + return "" + Character.toTitleCase(in.charAt(0)) + in.substring(1).toLowerCase(); + } + } +} -- cgit