From 503607efe854418dfb21088feb5a23732b997f59 Mon Sep 17 00:00:00 2001 From: Edward Jensen Date: Fri, 20 May 2022 11:10:56 -0500 Subject: [PATCH] Fix ClassCastException when using StringBuilder/Buffer mozilla#496 --- .../org/mozilla/javascript/tests/Issue1206Test.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/testsrc/org/mozilla/javascript/tests/Issue1206Test.java b/testsrc/org/mozilla/javascript/tests/Issue1206Test.java index 0e961a3418..52f35f2493 100644 --- a/testsrc/org/mozilla/javascript/tests/Issue1206Test.java +++ b/testsrc/org/mozilla/javascript/tests/Issue1206Test.java @@ -4,6 +4,8 @@ package org.mozilla.javascript.tests; +import junit.framework.TestCase; + import org.junit.Test; import org.mozilla.javascript.Context; import org.mozilla.javascript.Scriptable; @@ -11,13 +13,14 @@ /** * Tests the ConsString class to ensure it properly supports String, StringBuffer and StringBuilder. */ -public class Issue1206Test { +public class Issue1206Test extends TestCase { @Test public void testConsStringUsingString() { Context cx = Context.enter(); Scriptable scope = cx.initStandardObjects(null); scope.put("var1", scope, "hello"); - cx.evaluateString(scope, "var1 = var1 + ' world'", "test", 1, null); + Object result = cx.evaluateString(scope, "var1 = var1 + ' world'", "test", 1, null); + assertEquals("hello world", result); } @Test @@ -25,7 +28,8 @@ public void testConsStringUsingStringBuffer() { Context cx = Context.enter(); Scriptable scope = cx.initStandardObjects(null); scope.put("var1", scope, new StringBuffer("hello")); - cx.evaluateString(scope, "var1 = var1 + ' world'", "test", 1, null); + Object result = cx.evaluateString(scope, "var1 = var1 + ' world'", "test", 1, null); + assertEquals("hello world", result); } @Test @@ -33,6 +37,7 @@ public void testConsStringUsingStringBuilder() { Context cx = Context.enter(); Scriptable scope = cx.initStandardObjects(null); scope.put("var1", scope, new StringBuilder("hello")); - cx.evaluateString(scope, "var1 = var1 + ' world'", "test", 1, null); + Object result = cx.evaluateString(scope, "var1 = var1 + ' world'", "test", 1, null); + assertEquals("hello world", result); } }