Improve yield support and restrict usage of strict

- Partially reverting 91cdb93e57 and eaf3911c31 and reimplement
- Add generators support for objects and classes
- Only classes can have static methods so restrict use of it

Special thanks to @rvanvelzen and @kzc for reviewing this patch and
providing constructive feedback over and over again.
This commit is contained in:
Anthony Van de Gejuchte
2016-05-26 17:00:37 +02:00
parent 8ad8d7b717
commit dcfc514c38
10 changed files with 318 additions and 32 deletions

20
test/mocha/object.js Normal file
View File

@@ -0,0 +1,20 @@
var Uglify = require("../../");
var assert = require("assert");
describe("Object", function() {
it ("Should allow objects to have a methodDefinition as property", function() {
var code = "var a = {test() {return true;}}";
assert.equal(Uglify.minify(code, {fromString: true}).code, "var a={test(){return!0}};");
});
it ("Should not allow objects to use static keywords like in classes", function() {
var code = "{static test() {}}";
var parse = function() {
Uglify.parse(code);
}
var expect = function(e) {
return e instanceof Uglify.JS_Parse_Error;
}
assert.throws(parse, expect);
});
});