Bug in Number.prototype.toFixed for 0.5 and -0.5

2015-09-02 Thread Esben Andreasen
= n / 1 - 0.5 = n - 0.5 which solves to `n = 0` or `n = 1`. It seems that Nashorn picks the `n = 0` case instead of the `n = 1` case. --- Esben Andreasen

Bug: ClassCastException for arguments variable (plain JavaScript)

2016-09-15 Thread Esben Andreasen
Nashorn can produce a ClassCastException when executing a plain JavaScript program. The exception happens in a situation where the arguments variable is used in conjunction with call and apply. ## Observed behavior Code: ``` function F(SOME_PARAMETER) { Function.prototype.call.apply(G, argumen

[no subject]

2016-10-16 Thread Esben Andreasen
Hi I am not sure if this is a bug or feature of the Nashorn engine. But it looks like some String-prototype methods are missing, yet the methods are somehow present when used in the right way. Minimal example: calling `startsWith` by using `call`: ``` 1 $ jjs -v 2 jjs> String.prototype.startsW

Surprising Nashorn behavior for String methods

2016-10-16 Thread Esben Andreasen
Hi I am not sure if this is a bug or feature of the Nashorn engine. But it looks like some String-prototype methods are missing, yet the methods are somehow present when used in the right way. Minimal example: calling `startsWith` by using `call`: ``` 1 $ jjs -v 2 jjs> String.prototype.startsW

Re:

2016-10-17 Thread Esben Andreasen
abc", "a") > > Finally, .startsWith is only present on primitive String values (as > they’re java.lang.String), not on JS String objects, that’s why you were > getting results you didn’t expect from “typeof Object(string).startsWith” > > HTH, > Attila. > > > &g

Surprising difference between /usr/bin/jjs and .getEngineByName("JavaScript")

2016-12-21 Thread Esben Andreasen
Hi I am not sure if this is a bug or a problem with my setup. I observe a surprising difference between the "external" (jjs) and the "internal" (new ScriptEngineManager().getEngineByName("JavaScript")) Nashorn when evaluating a regular expression method. The two Nashorns seems to be the same, but

Re: Surprising difference between /usr/bin/jjs and .getEngineByName("JavaScript")

2016-12-21 Thread Esben Andreasen
when it is > returned by a script. > > Hannes > > > > Am 21.12.2016 <21%2012%2020%2016> um 11:09 schrieb Esben Andreasen < > es...@esbena.dk>: > > > > Hi > > > > I am not sure if this is a bug or a problem with my setup. > > I o

Minor discepancy for multiline regexps

2017-01-06 Thread Esben Andreasen
Hi I stumbled upon a minor discrepancy between Nashorn and other JavaScript engines when doing regexp matching with the multiline flag enabled. Nashorn ``` $ jjs -version nashorn 1.8.0_111 jjs> String.prototype.replace.apply("a\nb\rc\n\rd\r\ne", [/^(.*)/gm,"*$1"]); *a *c ** *e ``` Notice that th