@@ -22,6 +22,7 @@ record Person(String name, int age) {
2222 public String bla () {
2323 return name + age ;
2424 }
25+ public String name () {return name +"!" ;}
2526 }
2627
2728 record PersonWithAddress (String name , int age , Address address ) {}
@@ -36,7 +37,7 @@ private PugEngine newJexlEngine(String pug) throws Exception {
3637 }
3738
3839 @ Test
39- public void rendersRecordComponentsWithDotAccess () throws Exception {
40+ public void graalRendersRecordComponentsWithDotAccess () throws Exception {
4041 String pug = "h1= person.name\n p= person.age" ;
4142 PugEngine engine = newGraalEngine (pug );
4243 PugTemplate template = engine .getTemplate ("inline" );
@@ -47,7 +48,7 @@ public void rendersRecordComponentsWithDotAccess() throws Exception {
4748 String html = engine .render (template , model );
4849 // Depending on GraalJS member resolution, this may or may not work; keep as documentation of
4950 // desired behavior
50- assertEquals ("<h1>Alice</h1><p>42</p>" , html );
51+ assertEquals ("<h1>Alice! </h1><p>42</p>" , html );
5152 }
5253
5354 @ Test
@@ -64,9 +65,8 @@ public void rendersNestedRecordComponentsWithDotAccess() throws Exception {
6465 }
6566
6667 @ Test
67- @ Ignore (
68- "GraalJS does not support method call syntax for record components - use property access instead (person.name not person.name())" )
69- public void rendersRecordComponentsWithMethodCalls () throws Exception {
68+ // @Test(expected = RuntimeException.class)
69+ public void graalRendersRecordComponentsWithMethodCalls () throws Exception {
7070 String pug = "h1= person.name()\n p= person.age()" ;
7171 PugEngine engine = newGraalEngine (pug );
7272 PugTemplate template = engine .getTemplate ("inline" );
@@ -75,13 +75,11 @@ public void rendersRecordComponentsWithMethodCalls() throws Exception {
7575 model .put ("person" , new Person ("Alice" , 42 ));
7676
7777 String html = engine .render (template , model );
78- assertEquals ("<h1>Alice</h1><p>42</p>" , html );
78+ assertEquals ("<h1>Alice! </h1><p>42</p>" , html );
7979 }
8080
8181 @ Test
82- @ Ignore (
83- "GraalJS does not support method call syntax for records - use property access instead (person.address.city not person.address().city())" )
84- public void rendersNestedRecordComponentsWithMethodCalls () throws Exception {
82+ public void graalRendersNestedRecordComponentsWithMethodCalls () throws Exception {
8583 String pug = "h1= person.address().city()\n p= person.address().zip()" ;
8684 PugEngine engine = newGraalEngine (pug );
8785 PugTemplate template = engine .getTemplate ("inline" );
@@ -105,7 +103,7 @@ public void jexlRendersRecordComponentsWithDotAccess() throws Exception {
105103 String html = engine .render (template , model );
106104 // Depending on GraalJS member resolution, this may or may not work; keep as documentation of
107105 // desired behavior
108- assertEquals ("<h1>Alice</h1><p>42</p>" , html );
106+ assertEquals ("<h1>Alice! </h1><p>42</p>" , html );
109107 }
110108
111109 @ Test
@@ -131,7 +129,7 @@ public void jexlRendersRecordComponentsWithMethodCalls() throws Exception {
131129 model .put ("person" , new Person ("Alice" , 42 ));
132130
133131 String html = engine .render (template , model );
134- assertEquals ("<h1>Alice</h1><p>42</p>" , html );
132+ assertEquals ("<h1>Alice! </h1><p>42</p>" , html );
135133 }
136134
137135 @ Test
@@ -253,7 +251,7 @@ public void graalHandlesRecordWithNullComponent() throws Exception {
253251
254252 @ Test
255253 public void jexlHandlesRecordInInterpolation () throws Exception {
256- String pug = "p Hello, #{person.name}! You are #{person.age} years old." ;
254+ String pug = "p Hello, #{person.name} You are #{person.age} years old." ;
257255 PugEngine engine = newJexlEngine (pug );
258256 PugTemplate template = engine .getTemplate ("inline" );
259257
@@ -266,7 +264,7 @@ public void jexlHandlesRecordInInterpolation() throws Exception {
266264
267265 @ Test
268266 public void graalHandlesRecordInInterpolation () throws Exception {
269- String pug = "p Hello, #{person.name}! You are #{person.age} years old." ;
267+ String pug = "p Hello, #{person.name} You are #{person.age} years old." ;
270268 PugEngine engine = newGraalEngine (pug );
271269 PugTemplate template = engine .getTemplate ("inline" );
272270
0 commit comments