rhino1.7.7.testsrc.tests.lc2.Methods.method-006.js 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.
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
gTestfile = 'method-006.js';
/**
File Name: method-006.js
Description:
Assigning a Java method to a JavaScript object should not change the
context associated with the Java method -- its this object should
be the Java object, not the JavaScript object.
That is from Flanagan. In practice, this fails all implementations.
@author [email protected]
@version 1.00
*/
var SECTION = "LiveConnect Objects";
var VERSION = "1_3";
var TITLE = "Assigning a Non-Static Java Method to a JavaScript Object";
startTest();
writeHeaderToLog( SECTION + " "+ TITLE);
var java_string = new java.lang.String("LiveConnect");
var js_string = "JavaScript";
DESCRIPTION = "var java_string = new java.lang.String(\"LiveConnect\");" +
"var js_string = \"JavaScript\"" +
"js_string.startsWith = java_string.startsWith"+
"js_string.startsWith(\"J\")";
EXPECTED = "error";
js_string.startsWith = java_string.startsWith;
new TestCase(
SECTION,
"var java_string = new java.lang.String(\"LiveConnect\");" +
"var js_string = \"JavaScript\"" +
"js_string.startsWith = java_string.startsWith"+
"js_string.startsWith(\"J\")",
true,
js_string.startsWith("J") );
test();
function MyObject() {
this.println = java.lang.System.out.println;
this.classForName = java.lang.Class.forName;
return this;
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy