I noticed that many functions are not implemented, and some uncommon behaviour is not supported (eg: [1,2,,,5]), but those are not common problems.
You will find many inconsistencies by running the tests here, but I will list the most likely to affect users:
Unexpected if behaviour
var asd = 1;
if ( undefined )
asd = 2;
console.log('asd is:', asd); // 1 - is actually 2
Math.abs(-5) === 5, Math.log(Math.E*Math.E) === 2 and Math.log(1) === 0 should return true, but return false
no Date object
Number.POSITIVE_INFINITY === Infinity should be true but is actually false, same for NEGATIVE_INFINITY
(8.5).toString(16) should be 8.8 but found 8.5
(-8.5).toString(16) should be -8.8 but found -8.5
09 should be 9 but found 0
019 should be 19 but found 1
var i = -8; i >>>= 24 should be 255 but found 1099511627775
Math.PI should be 3.141592653589793 but found 3.141592653590000061569
Math.E should be 2.718281828459045 but found 2.718281828459999882596
Math.atan2(-1, Infinity) should be negative 0 (so -0) but found NaN
toFixed does not work although I remember @Gordon saying it was implemented
'abc' ? 1 : 2 should be 1 but found 2
Trying to delete non-deletable properties eg: delete Array.prototype should return false but object is returned. delete always returns the value, so it's impossible to tell if the property was deleted or not from its return.
Redefining a var inside the same scope does not work
var a = 'asd';
console.log(a); // asd
var a;
console.log(a); // undefined - is actually asd
no unicode
var u = "a\u1234c";
console.log(u.charCodeAt(1)) // 4660 - is actually 117
the for (x in y) works differently with {}, for example the following code behaves differently if curly braces are used to wrap {propnames.push(i);}, view the comments.
var arr = new Array('a','b','c');
var propnames = [];
for (var i in arr)
propnames.push(i);
console.log(propnames.length); // 3 - is actually 1
console.log(propnames[0]); // 0 - is actually 2
console.log(propnames[1]); // 1 - is actually undefined
console.log(propnames[2]); // 2 - is actually undefined
Other than not-yet-implemented functions and these examples, most tests in here run ok.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I noticed that many functions are not implemented, and some uncommon behaviour is not supported (eg: [1,2,,,5]), but those are not common problems.
You will find many inconsistencies by running the tests here, but I will list the most likely to affect users:
Unexpected
if
behaviourMath.abs(-5) === 5
,Math.log(Math.E*Math.E) === 2
andMath.log(1) === 0
should returntrue
, but returnfalse
no
Date
objectNumber.POSITIVE_INFINITY === Infinity
should be true but is actually false, same forNEGATIVE_INFINITY
(8.5).toString(16)
should be8.8
but found8.5
(-8.5).toString(16)
should be-8.8
but found-8.5
09
should be9
but found0
019
should be19
but found1
var i = -8; i >>>= 24
should be255
but found1099511627775
Math.PI
should be3.141592653589793
but found3.141592653590000061569
Math.E
should be2.718281828459045
but found2.718281828459999882596
Math.atan2(-1, Infinity)
should be negative0
(so-0
) but foundNaN
toFixed
does not work although I remember @Gordon saying it was implemented'abc' ? 1 : 2
should be1
but found2
Trying to
delete
non-deletable properties eg:delete Array.prototype
should returnfalse
but object is returned.delete
always returns the value, so it's impossible to tell if the property was deleted or not from its return.Redefining a var inside the same scope does not work
no unicode
the
for (x in y)
works differently with {}, for example the following code behaves differently if curly braces are used to wrap{propnames.push(i);}
, view the comments.Other than not-yet-implemented functions and these examples, most tests in here run ok.