rhino1.7.6.testsrc.doctests.784358.doctest 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/.
// https://bugzilla.mozilla.org/show_bug.cgi?id=784358
js> var v1=1
js> v1
1
js> eval("var v2=1")
js> v2
1
js> const c1=1
js> c1
1
js> eval("const c2=1")
js> c2
1
js> try {eval("const v1=2")}catch(e){e instanceof TypeError}
true
js> try {eval("const v1=2")}catch(e){e instanceof TypeError}
true
js> try{eval("const c1=1")}catch(e){e instanceof TypeError}
true
js> try{eval("const c2=1")}catch(e){e instanceof TypeError}
true
js> try{eval("var c1=1")}catch(e){e instanceof TypeError}
true
js> try{eval("var c2=1")}catch(e){e instanceof TypeError}
true
js> try {(1,eval)("const v1=2")}catch(e){e instanceof TypeError}
true
js> try {(1,eval)("const v1=2")}catch(e){e instanceof TypeError}
true
js> try{(1,eval)("const c1=1")}catch(e){e instanceof TypeError}
true
js> try{(1,eval)("const c2=1")}catch(e){e instanceof TypeError}
true
js> try{(1,eval)("var c1=1")}catch(e){e instanceof TypeError}
true
js> try{(1,eval)("var c2=1")}catch(e){e instanceof TypeError}
true
js> (function(){eval("const v1=2"); return v1})()
2
js> (function(){eval("const v2=2"); return v2})()
2
js> (function(){eval("const c1=2"); return c1})()
2
js> (function(){eval("const c2=2"); return c2})()
2
js> (function(){eval("var c1=2"); return c1})()
2
js> (function(){eval("var c2=2"); return c2})()
2
js> try{ (function(){(1,eval)("const v1=1")})() }catch(e){e instanceof TypeError}
true
js> try{ (function(){(1,eval)("const v2=1")})() }catch(e){e instanceof TypeError}
true
js> try{ (function(){(1,eval)("const c1=1")})() }catch(e){e instanceof TypeError}
true
js> try{ (function(){(1,eval)("const c2=1")})() }catch(e){e instanceof TypeError}
true
js> try{ (function(){(1,eval)("var c1=1")})() }catch(e){e instanceof TypeError}
true
js> try{ (function(){(1,eval)("var c2=1")})() }catch(e){e instanceof TypeError}
true
js> (v1 = 3, v1)
3
js> (v2 = 3, v2)
3
js> (c1 = 3, c1)
1
js> (c2 = 3, c2)
1
js> delete v1
false
js> delete v2
true
js> delete c1
false
js> delete c2
false
js> try{ (function(){const c1=1; eval("const c1=1")})() }catch(e){e instanceof TypeError}
true
js> try{ (function(){eval("const c1=1"); const c1=1})() }catch(e){e instanceof TypeError}
true
js> try{ (function(){eval("const c1=1"); eval("const c1=1")})() }catch(e){e instanceof TypeError}
true
js> try{ (function(){const c1=1; eval("var c1=1")})() }catch(e){e instanceof TypeError}
true
js> try{ (function(){eval("var c1=1"); const c1=1})() }catch(e){e instanceof TypeError}
true
js> try{ (function(){var c1=1; eval("const c1=1")})() }catch(e){e instanceof TypeError}
true
© 2015 - 2024 Weber Informatics LLC | Privacy Policy