fix class tests to reflect new call behaviour

This commit is contained in:
Sebastian McKenzie 2015-02-03 15:35:24 +11:00
parent 895d965568
commit 72de8f5c9b
15 changed files with 50 additions and 24 deletions

View File

@ -1,5 +1,5 @@
(function (Constructor) {
(function (instance, Constructor) {
if (Object.getPrototypeOf(Constructor) !== null) {
Object.getPrototypeOf(Constructor).apply(this, arguments);
Object.getPrototypeOf(Constructor).apply(instance, arguments);
}
});

View File

@ -177,7 +177,9 @@ Class.prototype.buildBody = function () {
}, true));
} else {
constructor.body.body.push(
t.expressionStatement(t.callExpression(this.file.addHelper(helperName), [className]))
t.expressionStatement(
t.callExpression(this.file.addHelper(helperName), [t.thisExpression(), className])
)
);
}
}

View File

@ -114,10 +114,10 @@ var run = function (task, done) {
var consumer = new sourceMap.SourceMapConsumer(result.map);
_.each(task.sourceMappings, function (mapping, i) {
var expect = mapping.original;
var actual = mapping.original;
var actual = consumer.originalPositionFor(mapping.generated);
chai.expect({ line: actual.line, column: actual.column }).to.deep.equal(expect);
var expect = consumer.originalPositionFor(mapping.generated);
chai.expect({ line: expect.line, column: expect.column }).to.deep.equal(actual);
});
}
};

View File

@ -1,4 +1,8 @@
"use strict";
var Test = function Test() {};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9iYXIvYmFyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0lBQU0sZ0JBQUEiLCJmaWxlIjoic3JjL2Jhci9iYXIuanMiLCJzb3VyY2VzQ29udGVudCI6WyJjbGFzcyBUZXN0IHtcblxufSJdfQ==
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var Test = function Test() {
_classCallCheck(this, Test);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9iYXIvYmFyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7SUFBTSxnQkFBQTt3QkFBQSIsImZpbGUiOiJzcmMvYmFyL2Jhci5qcyIsInNvdXJjZXNDb250ZW50IjpbImNsYXNzIFRlc3Qge1xuXG59Il19

View File

@ -1,4 +1,8 @@
"use strict";
var Test = function Test() {};
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var Test = function Test() {
_classCallCheck(this, Test);
};
//# sourceMappingURL=bar.js.map

View File

@ -1 +1 @@
{"version":3,"sources":["src/bar/bar.js"],"names":[],"mappings":";;IAAM,gBAAA","file":"src/bar/bar.js","sourcesContent":["class Test {\n\n}"]}
{"version":3,"sources":["src/bar/bar.js"],"names":[],"mappings":";;;;IAAM,gBAAA;wBAAA","file":"src/bar/bar.js","sourcesContent":["class Test {\n\n}"]}

View File

@ -1,3 +1,7 @@
"use strict";
var Test = function Test() {};
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var Test = function Test() {
_classCallCheck(this, Test);
};

View File

@ -1,10 +1,14 @@
"use strict";
var Test = function Test() {};
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var Test = function Test() {
_classCallCheck(this, Test);
};
"use strict";
arr.map(function (x) {
return x * MULTIPLIER;
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7SUFBTSxnQkFBQTs7OztBQ0FOLElBQUksSUFBSSxVQUFBO1NBQUssSUFBSSIsImZpbGUiOiJzY3JpcHQzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgVGVzdCB7XG5cbn0iLCJhcnIubWFwKHggPT4geCAqIE1VTFRJUExJRVIpOyJdfQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztJQUFNLGdCQUFBO3dCQUFBOzs7OztBQ0FOLElBQUksSUFBSSxVQUFBO1NBQUssSUFBSSIsImZpbGUiOiJzY3JpcHQzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgVGVzdCB7XG5cbn0iLCJhcnIubWFwKHggPT4geCAqIE1VTFRJUExJRVIpOyJdfQ==

View File

@ -1,6 +1,10 @@
"use strict";
var Test = function Test() {};
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var Test = function Test() {
_classCallCheck(this, Test);
};
"use strict";
arr.map(function (x) {

View File

@ -1 +1 @@
{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":";;IAAM,gBAAA;;;;ACAN,IAAI,IAAI,UAAA;SAAK,IAAI","file":"script3.js","sourcesContent":["class Test {\n\n}","arr.map(x => x * MULTIPLIER);"]}
{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":";;;;IAAM,gBAAA;wBAAA;;;;;ACAN,IAAI,IAAI,UAAA;SAAK,IAAI","file":"script3.js","sourcesContent":["class Test {\n\n}","arr.map(x => x * MULTIPLIER);"]}

View File

@ -1,6 +1,10 @@
"use strict";
var Test = function Test() {};
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var Test = function Test() {
_classCallCheck(this, Test);
};
"use strict";
arr.map(function (x) {

View File

@ -1,6 +1,6 @@
"use strict";
var _classSuperConstructorCall = function (Constructor) { if (Object.getPrototypeOf(Constructor) !== null) { Object.getPrototypeOf(Constructor).apply(this, arguments); } };
var _classSuperConstructorCall = function (instance, Constructor) { if (Object.getPrototypeOf(Constructor) !== null) { Object.getPrototypeOf(Constructor).apply(instance, arguments); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
@ -10,7 +10,7 @@ var BaseController = (function (_Chaplin$Controller) {
function BaseController() {
_classCallCheck(this, BaseController);
_classSuperConstructorCall(BaseController);
_classSuperConstructorCall(this, BaseController);
}
_inherits(BaseController, _Chaplin$Controller);
@ -22,7 +22,7 @@ var BaseController2 = (function (_Chaplin$Controller$Another) {
function BaseController2() {
_classCallCheck(this, BaseController2);
_classSuperConstructorCall(BaseController2);
_classSuperConstructorCall(this, BaseController2);
}
_inherits(BaseController2, _Chaplin$Controller$Another);

View File

@ -1,6 +1,6 @@
"use strict";
var _classSuperConstructorCall = function (Constructor) { if (Object.getPrototypeOf(Constructor) !== null) { Object.getPrototypeOf(Constructor).apply(this, arguments); } };
var _classSuperConstructorCall = function (instance, Constructor) { if (Object.getPrototypeOf(Constructor) !== null) { Object.getPrototypeOf(Constructor).apply(instance, arguments); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
@ -10,7 +10,7 @@ var Test = (function (Foo) {
function Test() {
_classCallCheck(this, Test);
_classSuperConstructorCall(Test);
_classSuperConstructorCall(this, Test);
}
_inherits(Test, Foo);

View File

@ -4,7 +4,7 @@
"column": 10
},
"generated": {
"line": 11,
"line": 15,
"column": 15
}
}]

View File

@ -2,7 +2,7 @@
var _defaults = function (obj, defaults) { for (var key in defaults) { if (obj[key] === undefined) { obj[key] = defaults[key]; } } return obj; };
var _classSuperConstructorCall = function (Constructor) { if (Object.getPrototypeOf(Constructor) !== null) { Object.getPrototypeOf(Constructor).apply(this, arguments); } };
var _classSuperConstructorCall = function (instance, Constructor) { if (Object.getPrototypeOf(Constructor) !== null) { Object.getPrototypeOf(Constructor).apply(instance, arguments); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) _defaults(subClass, superClass); };
@ -12,7 +12,7 @@ var Foo = (function (Bar) {
function Foo() {
_classCallCheck(this, Foo);
_classSuperConstructorCall(Foo);
_classSuperConstructorCall(this, Foo);
}
_inherits(Foo, Bar);