rhino1.7.7.testsrc.org.mozilla.javascript.tests.BugGetterSetterTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rhino Show documentation
Show all versions of rhino Show documentation
Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically
embedded into Java applications to provide scripting to end users.
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.javascript.tests;
import org.junit.Before;
import org.junit.Test;
import org.mozilla.javascript.CompilerEnvirons;
import org.mozilla.javascript.Parser;
import org.mozilla.javascript.ast.AstRoot;
import java.io.IOException;
import java.io.StringReader;
import static junit.framework.Assert.assertEquals;
public class BugGetterSetterTest {
private CompilerEnvirons environment = new CompilerEnvirons();
@Before
public void setUp() throws Exception {
environment.setLanguageVersion(180);
environment.setStrictMode(false);
}
@Test
public void testNodeReplacementInWhileLoopWithBrackets() throws IOException {
String script = "var o = {\n" +
" _x: 123, \n" +
" get x() {\n" +
" return this._x;\n" +
" }\n" +
", \n" +
" set x(value) {\n" +
" this._x = value;\n" +
" }\n" +
"};\n";
Parser parser = new Parser(environment);
AstRoot astRoot = parser.parse(new StringReader(script), null, 1);
assertEquals(script, astRoot.toSource());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy