|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -51,6 +51,7 @@ public static void main(String... args) throws Exception {
|
51 | 51 | test.testFields();
|
52 | 52 | test.testModules();
|
53 | 53 | test.testAnnotations();
|
| 54 | + test.testRecords(); |
54 | 55 | }
|
55 | 56 |
|
56 | 57 | public void testMethods() throws Exception {
|
@@ -191,6 +192,36 @@ public void testModules() throws Exception {
|
191 | 192 | true);
|
192 | 193 | }
|
193 | 194 |
|
| 195 | + public void testRecords() throws Exception { |
| 196 | + doOrdinaryTest("package test; public record Test (int x, int y) { }", |
| 197 | + "package test; public record Test (int x, int y) { }", // identical |
| 198 | + false); |
| 199 | + doOrdinaryTest("package test; public record Test (int x, int y) { }", |
| 200 | + "package test; public record Test (int x, int y) {" + |
| 201 | + "public Test { } }", // compact ctr |
| 202 | + false); |
| 203 | + doOrdinaryTest("package test; public record Test (int x, int y) { }", |
| 204 | + "package test; public record Test (int x, int y) {" + |
| 205 | + "public Test (int x, int y) { this.x=x; this.y=y;} }", // canonical ctr |
| 206 | + false); |
| 207 | + doOrdinaryTest("package test; public record Test (int x, int y) { }", |
| 208 | + "package test; public record Test (int y, int x) { }", // reverse |
| 209 | + true); |
| 210 | + doOrdinaryTest("package test; public record Test (int x, int y) { }", |
| 211 | + "package test; public record Test (int x, int y, int z) { }", // additional |
| 212 | + true); |
| 213 | + doOrdinaryTest("package test; public record Test (int x, int y) { }", |
| 214 | + "package test; public record Test () { }", // empty |
| 215 | + true); |
| 216 | + doOrdinaryTest("package test; public record Test (int x, int y) { }", |
| 217 | + "package test; /*package*/ record Test (int x, int y) { }", // package |
| 218 | + true); |
| 219 | + doOrdinaryTest("package test; public record Test (int x, int y) { }", |
| 220 | + "package test; public record Test (int x, int y) {" + |
| 221 | + "public Test (int x, int y, int z) { this(x, y); } }", // additional ctr |
| 222 | + true); |
| 223 | + } |
| 224 | + |
194 | 225 | private final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
195 | 226 | private Path depend;
|
196 | 227 | private Path scratchServices;
|
|
0 commit comments