Problems with JS implementation #224
Replies: 11 comments
-
Posted at 2014-02-13 by randunel I have attached a file, if anyone wants to run the tests on their espruino. It contains a limited set of browser tests adapted to work on our devices.Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-14 by TiCPU For the octal part, 019 gets me an non-octal SyntaxError in Firefox, however, Espruino doesn't handle exceptions at the moment, so I guess either it should stay as-is or output NaN. As for the 2 constants, I guess this is a normal behaviour in the case of how floats are implemented on hardware. It can not be more precise than the hardware itself. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-14 by @gfwilliams Hi. Thanks for the post. It'd actually be really handy if you could split some of the tests and issue a pull request for: https://github.com/espruino/Espruino/tree/master/tests (these rely on a variable called 'result' being set to either true or false). At least then we could quantify and work towards fixing some of these (there's a handy graph here: http://www.espruino.com/binaries/git/stats.html). You've spotted some interesting behaviour. One that is major but that I hadn't noticed is that I'll try and sort some of those issues out - however I won't manage to get everything done... The hardware interface side of things needs a lot of work too but tends to get ignored because it's not as easy to test as just running JS language tests :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-14 by @gfwilliams Just to add: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-14 by @gfwilliams Also, just wanted to say: some bits of JS are nasty and it pains me to implement them.
But...
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-14 by @gfwilliams Ok, a bunch of these are now fixed. Your bug with If you write it in the console it's much more obvious what the problem is, because as you hit enter after the first line, Espruino executes it.
Both print
And the Web IDE does basically just paste code into the console, when it ought to do something a bit more interesting. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-14 by randunel Allright I'll test against the latest dev version after work or tomorrow, and send proper pull requests if problems persist. Thanks for looking into this. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-20 by hansamann I saw that you mentioned exception are not supported right now. I am using the Adafruit CC3000 breakout and try to run a http post every 5 seconds to report some button states. I get a
very often or the cc3000 dies altogether and making the espruino unresponsive and not run any code. Is there any way to recover from such an exception right now? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-20 by @gfwilliams Could you start a new post for that please? I guess it's possible that the CC3000 has become disconnected from the internet. I guess it's possible that Espruino doesn't recover properly if the request fails at that point. The worst that should happen is that it hangs for 10 seconds, times out, and then reboots the CC3000. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-28 by mattbrailsford I just thought I'd add another item I've just come across, rather than starting a new post (unless you have a preferred way of people reporting JS syntax issues?). In JS, it's common practice to namespace your code, which can be done in a number of ways, but the simplest way by far is
This currently doesn't work however as rather than just reporting the variable as null and then falling back to the blank object, it actually errors with "Field or method does not already exist". Matt |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-03 by @gfwilliams Hi Matt, Probably the best place for this kind of thing is the Espruino github issue tracker. I've just made a bug for this: espruino/Espruino#251 The issue is that currently |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-13 by randunel
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:
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
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.
Beta Was this translation helpful? Give feedback.
All reactions