gkz / LiveScript

LiveScript is a language which compiles to JavaScript. It has a straightforward mapping to JavaScript and allows you to write expressive code devoid of repetitive boilerplate. While LiveScript adds many features to assist in functional style programming, it also has many improvements for object oriented and imperative programming.
http://livescript.net
MIT License
2.31k stars 156 forks source link

Feature detection in the test environment #1061

Closed pepkin88 closed 5 years ago

pepkin88 commented 5 years ago

Currently it was easy to miss testing generators, because of omitting the --harmony flag; even make full skipped testing generators. This PR introduces detecting support for certain syntax oriented language features, before running tests.

This doesn't mean the tests will always run/pass on the older Node versions, as sometimes other new features are used, which are not syntax oriented, such as String::startsWith. The purpose of this PR is however to be able to always rely on the default npm test or make full and be sure, that having the newest runtime environment set up, all the tests will run.

pepkin88 commented 5 years ago

I left all the harmony related scrips/commands intact to preserve backwards compatibility. Although using them will be now obsolete.

rhendric commented 5 years ago

I think we can be more aggressive than this. I'm comfortable saying that Node.js 4 is the earliest Node we support running tests on, so you can remove the generator check entirely. I would also support ripping out the test-harmony infrastructure; I don't care about backwards compatibility for people running LS tests. There aren't that many of us, after all.

pepkin88 commented 5 years ago

I noticed that tests are buggy for Node versions <5.10, because of a different implementation of Buffer.from function, which exists, but can only process typed arrays.

pepkin88 commented 5 years ago

It affects not only tests, but compilation in general, when compiling with embedded source maps.

rhendric commented 5 years ago

It looks like this only impacts the Node 5 line? Node 4.9.1 doesn't seem to have any problems for me.

pepkin88 commented 5 years ago

I have tested on v4.0.0 and v5.0.0 and those gave me errors. Version 4.9.1 indeed has the newer implementation.

It seems that checking for existence of Buffer.alloc is enough to ensure, that Buffer.from has the modern implementation.


Node v4.5.0 is the first from 4.x branch with the new behavior.

pepkin88 commented 5 years ago

I addressed this issue in another PR: #1062.