changeset 48236:85ea92261382 datum

additional tests for guards in records
author vromero
date Thu, 30 Nov 2017 17:43:52 -0500
parents 08f552df175c
children 44c9d8007630
files test/langtools/tools/javac/datum/GuardsInRecordsTest.java
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/langtools/tools/javac/datum/GuardsInRecordsTest.java	Thu Nov 30 17:16:20 2017 -0500
+++ b/test/langtools/tools/javac/datum/GuardsInRecordsTest.java	Thu Nov 30 17:43:52 2017 -0500
@@ -38,6 +38,9 @@
         }
     }
 
+    static abstract record A (int a) where a >= 0;
+    static record B (int a, int b) extends A(a) where b >= 0;
+
     public static void main(String... args) {
         try {
             Range1 r = new Range1(2, 1);
@@ -53,5 +56,15 @@
             Range3 r = new Range3(2, 1);
             throw new AssertionError("an exception was expected for Range3");
         } catch (IllegalArgumentException iae) {}
+
+        try {
+            B b1 = new B(-1, 1);
+            throw new AssertionError("an exception was expected for B");
+        } catch (IllegalArgumentException iae) {}
+
+        try {
+            B b2 = new B(-1, -1);
+            throw new AssertionError("an exception was expected for B");
+        } catch (IllegalArgumentException iae) {}
     }
 }