Debian Codegraph @

rhino/testsrc/org/mozilla/javascript/tests/DecompileTest.java

raw symbols SCIP
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 package org.mozilla.javascript.tests;
6
7
8 import org.junit.Assert;
9 import org.junit.Test;
10 import org.mozilla.javascript.Context;
11 import org.mozilla.javascript.ContextAction;
12 import org.mozilla.javascript.Script;
13
14 /**
15 * Test for {@link Context#decompileScript(Script, int)}.
16 * @author Marc Guillemot
17 */
18 public class DecompileTest {
19
20 /**
21 * As of head of trunk on 30.09.09, decompile of "new Date()" returns "new Date" without parentheses.
22 * @see <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=519692">Bug 519692</a>
23 */
24 @Test
25 public void newObject0Arg()
26 {
27 final String source = "var x = new Date().getTime();";
28 final ContextAction action = new ContextAction() {
29 public Object run(final Context cx) {
30 final Script script = cx.compileString(source, "my script", 0, null);
31 Assert.assertEquals(source, cx.decompileScript(script, 4).trim());
32 return null;
33 }
34 };
35 Utils.runWithAllOptimizationLevels(action);
36 }
37 }