Skip to content

Commit

Permalink
Accepted baselines.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRosenwasser committed Sep 7, 2017
1 parent 00f88fc commit 587c8a8
Show file tree
Hide file tree
Showing 27 changed files with 300 additions and 111 deletions.
11 changes: 9 additions & 2 deletions tests/baselines/reference/asOperator3.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ var g = tag `Hello ${123} World` as string;
var h = tag `Hello` as string;

//// [asOperator3.js]
var __getTemplateObject = (this && this.__getTemplateObject) || function (cooked, raw) {
if (Object.freeze && Object.defineProperty) {
return Object.freeze(Object.defineProperty(cooked, "raw", { value: Object.freeze(raw) }));
}
cooked.raw = raw;
return cooked;
};
var a = "" + (123 + 456);
var b = "leading " + (123 + 456);
var c = 123 + 456 + " trailing";
var d = "Hello " + 123 + " World";
var e = "Hello";
var f = 1 + (1 + " end of string");
var g = (_a = ["Hello ", " World"], _a.raw = ["Hello ", " World"], tag(_a, 123));
var h = (_b = ["Hello"], _b.raw = ["Hello"], tag(_b));
var g = tag(_a || (_a = __getTemplateObject(["Hello ", " World"], ["Hello ", " World"])), 123);
var h = tag(_b || (_b = __getTemplateObject(["Hello"], ["Hello"])));
var _a, _b;
9 changes: 8 additions & 1 deletion tests/baselines/reference/asOperatorASI.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ as(Foo); // should emit


//// [asOperatorASI.js]
var __getTemplateObject = (this && this.__getTemplateObject) || function (cooked, raw) {
if (Object.freeze && Object.defineProperty) {
return Object.freeze(Object.defineProperty(cooked, "raw", { value: Object.freeze(raw) }));
}
cooked.raw = raw;
return cooked;
};
var Foo = /** @class */ (function () {
function Foo() {
}
return Foo;
}());
// Example 1
var x = 10;
(_a = ["Hello world"], _a.raw = ["Hello world"], as(_a)); // should not error
as(_a || (_a = __getTemplateObject(["Hello world"], ["Hello world"]))); // should not error
// Example 2
var y = 20;
as(Foo); // should emit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ function f(...args: any[]) {
f `\x0D${ "Interrupted CRLF" }\x0A`;

//// [taggedTemplateStringsHexadecimalEscapes.js]
var __getTemplateObject = (this && this.__getTemplateObject) || function (cooked, raw) {
if (Object.freeze && Object.defineProperty) {
return Object.freeze(Object.defineProperty(cooked, "raw", { value: Object.freeze(raw) }));
}
cooked.raw = raw;
return cooked;
};
function f() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
}
(_a = ["\r", "\n"], _a.raw = ["\\x0D", "\\x0A"], f(_a, "Interrupted CRLF"));
f(_a || (_a = __getTemplateObject(["\r", "\n"], ["\\x0D", "\\x0A"])), "Interrupted CRLF");
var _a;
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ function f(...x: any[]) {
f `0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n`

//// [taggedTemplateStringsPlainCharactersThatArePartsOfEscapes01.js]
var __getTemplateObject = (this && this.__getTemplateObject) || function (cooked, raw) {
if (Object.freeze && Object.defineProperty) {
return Object.freeze(Object.defineProperty(cooked, "raw", { value: Object.freeze(raw) }));
}
cooked.raw = raw;
return cooked;
};
function f() {
var x = [];
for (var _i = 0; _i < arguments.length; _i++) {
x[_i] = arguments[_i];
}
}
(_a = ["0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n"], _a.raw = ["0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n"], f(_a));
f(_a || (_a = __getTemplateObject(["0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n"], ["0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2028 2029 0085 t v f b r n"])));
var _a;
Original file line number Diff line number Diff line change
Expand Up @@ -92,67 +92,74 @@ var arr: any[];


//// [taggedTemplateStringsTypeArgumentInference.js]
var __getTemplateObject = (this && this.__getTemplateObject) || function (cooked, raw) {
if (Object.freeze && Object.defineProperty) {
return Object.freeze(Object.defineProperty(cooked, "raw", { value: Object.freeze(raw) }));
}
cooked.raw = raw;
return cooked;
};
// Generic tag with one parameter
function noParams(n) { }
(_a = [""], _a.raw = [""], noParams(_a));
noParams(_a || (_a = __getTemplateObject([""], [""])));
// Generic tag with parameter which does not use type parameter
function noGenericParams(n) { }
(_b = [""], _b.raw = [""], noGenericParams(_b));
noGenericParams(_b || (_b = __getTemplateObject([""], [""])));
// Generic tag with multiple type parameters and only one used in parameter type annotation
function someGenerics1a(n, m) { }
(_c = ["", ""], _c.raw = ["", ""], someGenerics1a(_c, 3));
someGenerics1a(_c || (_c = __getTemplateObject(["", ""], ["", ""])), 3);
function someGenerics1b(n, m) { }
(_d = ["", ""], _d.raw = ["", ""], someGenerics1b(_d, 3));
someGenerics1b(_d || (_d = __getTemplateObject(["", ""], ["", ""])), 3);
// Generic tag with argument of function type whose parameter is of type parameter type
function someGenerics2a(strs, n) { }
(_e = ["", ""], _e.raw = ["", ""], someGenerics2a(_e, function (n) { return n; }));
someGenerics2a(_e || (_e = __getTemplateObject(["", ""], ["", ""])), function (n) { return n; });
function someGenerics2b(strs, n) { }
(_f = ["", ""], _f.raw = ["", ""], someGenerics2b(_f, function (n, x) { return n; }));
someGenerics2b(_f || (_f = __getTemplateObject(["", ""], ["", ""])), function (n, x) { return n; });
// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
function someGenerics3(strs, producer) { }
(_g = ["", ""], _g.raw = ["", ""], someGenerics3(_g, function () { return ''; }));
(_h = ["", ""], _h.raw = ["", ""], someGenerics3(_h, function () { return undefined; }));
(_j = ["", ""], _j.raw = ["", ""], someGenerics3(_j, function () { return 3; }));
someGenerics3(_g || (_g = __getTemplateObject(["", ""], ["", ""])), function () { return ''; });
someGenerics3(_h || (_h = __getTemplateObject(["", ""], ["", ""])), function () { return undefined; });
someGenerics3(_j || (_j = __getTemplateObject(["", ""], ["", ""])), function () { return 3; });
// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
function someGenerics4(strs, n, f) { }
(_k = ["", "", ""], _k.raw = ["", "", ""], someGenerics4(_k, 4, function () { return null; }));
(_l = ["", "", ""], _l.raw = ["", "", ""], someGenerics4(_l, '', function () { return 3; }));
(_m = ["", "", ""], _m.raw = ["", "", ""], someGenerics4(_m, null, null));
someGenerics4(_k || (_k = __getTemplateObject(["", "", ""], ["", "", ""])), 4, function () { return null; });
someGenerics4(_l || (_l = __getTemplateObject(["", "", ""], ["", "", ""])), '', function () { return 3; });
someGenerics4(_m || (_m = __getTemplateObject(["", "", ""], ["", "", ""])), null, null);
// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
function someGenerics5(strs, n, f) { }
(_o = ["", " ", ""], _o.raw = ["", " ", ""], someGenerics5(_o, 4, function () { return null; }));
(_p = ["", "", ""], _p.raw = ["", "", ""], someGenerics5(_p, '', function () { return 3; }));
(_q = ["", "", ""], _q.raw = ["", "", ""], someGenerics5(_q, null, null));
someGenerics5(_o || (_o = __getTemplateObject(["", " ", ""], ["", " ", ""])), 4, function () { return null; });
someGenerics5(_p || (_p = __getTemplateObject(["", "", ""], ["", "", ""])), '', function () { return 3; });
someGenerics5(_q || (_q = __getTemplateObject(["", "", ""], ["", "", ""])), null, null);
// Generic tag with multiple arguments of function types that each have parameters of the same generic type
function someGenerics6(strs, a, b, c) { }
(_r = ["", "", "", ""], _r.raw = ["", "", "", ""], someGenerics6(_r, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
(_s = ["", "", "", ""], _s.raw = ["", "", "", ""], someGenerics6(_s, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
(_t = ["", "", "", ""], _t.raw = ["", "", "", ""], someGenerics6(_t, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
someGenerics6(_r || (_r = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), function (n) { return n; }, function (n) { return n; }, function (n) { return n; });
someGenerics6(_s || (_s = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), function (n) { return n; }, function (n) { return n; }, function (n) { return n; });
someGenerics6(_t || (_t = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), function (n) { return n; }, function (n) { return n; }, function (n) { return n; });
// Generic tag with multiple arguments of function types that each have parameters of different generic type
function someGenerics7(strs, a, b, c) { }
(_u = ["", "", "", ""], _u.raw = ["", "", "", ""], someGenerics7(_u, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
(_v = ["", "", "", ""], _v.raw = ["", "", "", ""], someGenerics7(_v, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
(_w = ["", "", "", ""], _w.raw = ["", "", "", ""], someGenerics7(_w, function (n) { return n; }, function (n) { return n; }, function (n) { return n; }));
someGenerics7(_u || (_u = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), function (n) { return n; }, function (n) { return n; }, function (n) { return n; });
someGenerics7(_v || (_v = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), function (n) { return n; }, function (n) { return n; }, function (n) { return n; });
someGenerics7(_w || (_w = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), function (n) { return n; }, function (n) { return n; }, function (n) { return n; });
// Generic tag with argument of generic function type
function someGenerics8(strs, n) { return n; }
var x = (_x = ["", ""], _x.raw = ["", ""], someGenerics8(_x, someGenerics7));
(_y = ["", "", "", ""], _y.raw = ["", "", "", ""], x(_y, null, null, null));
var x = someGenerics8(_x || (_x = __getTemplateObject(["", ""], ["", ""])), someGenerics7);
x(_y || (_y = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), null, null, null);
// Generic tag with multiple parameters of generic type passed arguments with no best common type
function someGenerics9(strs, a, b, c) {
return null;
}
var a9a = (_z = ["", "", "", ""], _z.raw = ["", "", "", ""], someGenerics9(_z, '', 0, []));
var a9a = someGenerics9(_z || (_z = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), '', 0, []);
var a9a;
var a9e = (_0 = ["", "", "", ""], _0.raw = ["", "", "", ""], someGenerics9(_0, undefined, { x: 6, z: new Date() }, { x: 6, y: '' }));
var a9e = someGenerics9(_0 || (_0 = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), undefined, { x: 6, z: new Date() }, { x: 6, y: '' });
var a9e;
// Generic tag with multiple parameters of generic type passed arguments with a single best common type
var a9d = (_1 = ["", "", "", ""], _1.raw = ["", "", "", ""], someGenerics9(_1, { x: 3 }, { x: 6 }, { x: 6 }));
var a9d = someGenerics9(_1 || (_1 = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), { x: 3 }, { x: 6 }, { x: 6 });
var a9d;
// Generic tag with multiple parameters of generic type where one argument is of type 'any'
var anyVar;
var a = (_2 = ["", "", "", ""], _2.raw = ["", "", "", ""], someGenerics9(_2, 7, anyVar, 4));
var a = someGenerics9(_2 || (_2 = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), 7, anyVar, 4);
var a;
// Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any'
var arr = (_3 = ["", "", "", ""], _3.raw = ["", "", "", ""], someGenerics9(_3, [], null, undefined));
var arr = someGenerics9(_3 || (_3 = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), [], null, undefined);
var arr;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,23 @@ f.thisIsNotATag(`abc${1}def${2}ghi`);


//// [taggedTemplateStringsWithIncompatibleTypedTags.js]
var __getTemplateObject = (this && this.__getTemplateObject) || function (cooked, raw) {
if (Object.freeze && Object.defineProperty) {
return Object.freeze(Object.defineProperty(cooked, "raw", { value: Object.freeze(raw) }));
}
cooked.raw = raw;
return cooked;
};
var f;
(_a = ["abc"], _a.raw = ["abc"], f(_a));
(_b = ["abc", "def", "ghi"], _b.raw = ["abc", "def", "ghi"], f(_b, 1, 2));
(_c = ["abc"], _c.raw = ["abc"], f(_c)).member;
(_d = ["abc", "def", "ghi"], _d.raw = ["abc", "def", "ghi"], f(_d, 1, 2)).member;
(_e = ["abc"], _e.raw = ["abc"], f(_e))["member"];
(_f = ["abc", "def", "ghi"], _f.raw = ["abc", "def", "ghi"], f(_f, 1, 2))["member"];
(_g = ["abc", "def", "ghi"], _g.raw = ["abc", "def", "ghi"], (_h = ["abc"], _h.raw = ["abc"], f(_h))[0].member(_g, 1, 2));
(_j = ["abc", "def", "ghi"], _j.raw = ["abc", "def", "ghi"], (_k = ["abc", "def", "ghi"], _k.raw = ["abc", "def", "ghi"], f(_k, 1, 2))["member"].member(_j, 1, 2));
(_l = ["abc", "def", "ghi"], _l.raw = ["abc", "def", "ghi"], (_m = ["abc", "def", "ghi"], _m.raw = ["abc", "def", "ghi"], f(_m, true, true))["member"].member(_l, 1, 2));
f(_a || (_a = __getTemplateObject(["abc"], ["abc"])));
f(_b || (_b = __getTemplateObject(["abc", "def", "ghi"], ["abc", "def", "ghi"])), 1, 2);
f(_c || (_c = __getTemplateObject(["abc"], ["abc"]))).member;
f(_d || (_d = __getTemplateObject(["abc", "def", "ghi"], ["abc", "def", "ghi"])), 1, 2).member;
f(_e || (_e = __getTemplateObject(["abc"], ["abc"])))["member"];
f(_f || (_f = __getTemplateObject(["abc", "def", "ghi"], ["abc", "def", "ghi"])), 1, 2)["member"];
f(_g || (_g = __getTemplateObject(["abc"], ["abc"])))[0].member(_h || (_h = __getTemplateObject(["abc", "def", "ghi"], ["abc", "def", "ghi"])), 1, 2);
f(_j || (_j = __getTemplateObject(["abc", "def", "ghi"], ["abc", "def", "ghi"])), 1, 2)["member"].member(_k || (_k = __getTemplateObject(["abc", "def", "ghi"], ["abc", "def", "ghi"])), 1, 2);
f(_l || (_l = __getTemplateObject(["abc", "def", "ghi"], ["abc", "def", "ghi"])), true, true)["member"].member(_m || (_m = __getTemplateObject(["abc", "def", "ghi"], ["abc", "def", "ghi"])), 1, 2);
f.thisIsNotATag("abc");
f.thisIsNotATag("abc" + 1 + "def" + 2 + "ghi");
var _a, _b, _c, _d, _e, _f, _h, _g, _k, _j, _m, _l;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ var x = new new new f `abc${ 0 }def`.member("hello")(42) === true;


//// [taggedTemplateStringsWithManyCallAndMemberExpressions.js]
var __getTemplateObject = (this && this.__getTemplateObject) || function (cooked, raw) {
if (Object.freeze && Object.defineProperty) {
return Object.freeze(Object.defineProperty(cooked, "raw", { value: Object.freeze(raw) }));
}
cooked.raw = raw;
return cooked;
};
var f;
var x = new new new (_a = ["abc", "def"], _a.raw = ["abc", "def"], f(_a, 0)).member("hello")(42) === true;
var x = new new new f(_a || (_a = __getTemplateObject(["abc", "def"], ["abc", "def"])), 0).member("hello")(42) === true;
var _a;
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ f `
`;

//// [taggedTemplateStringsWithMultilineTemplate.js]
var __getTemplateObject = (this && this.__getTemplateObject) || function (cooked, raw) {
if (Object.freeze && Object.defineProperty) {
return Object.freeze(Object.defineProperty(cooked, "raw", { value: Object.freeze(raw) }));
}
cooked.raw = raw;
return cooked;
};
function f() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
}
(_a = ["\n\n"], _a.raw = ["\n\\\n\n"], f(_a));
f(_a || (_a = __getTemplateObject(["\n\n"], ["\n\\\n\n"])));
var _a;
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ var z = foo `${1}${2}${3}`; // any (with error)


//// [taggedTemplateStringsWithOverloadResolution1.js]
var __getTemplateObject = (this && this.__getTemplateObject) || function (cooked, raw) {
if (Object.freeze && Object.defineProperty) {
return Object.freeze(Object.defineProperty(cooked, "raw", { value: Object.freeze(raw) }));
}
cooked.raw = raw;
return cooked;
};
function foo() {
var stuff = [];
for (var _i = 0; _i < arguments.length; _i++) {
Expand All @@ -36,10 +43,10 @@ var c = foo([], 1, 2); // boolean
var d = foo([], 1, true); // boolean (with error)
var e = foo([], 1, "2"); // {}
var f = foo([], 1, 2, 3); // any (with error)
var u = (_a = [""], _a.raw = [""], foo(_a)); // number
var v = (_b = ["", ""], _b.raw = ["", ""], foo(_b, 1)); // string
var w = (_c = ["", "", ""], _c.raw = ["", "", ""], foo(_c, 1, 2)); // boolean
var x = (_d = ["", "", ""], _d.raw = ["", "", ""], foo(_d, 1, true)); // boolean (with error)
var y = (_e = ["", "", ""], _e.raw = ["", "", ""], foo(_e, 1, "2")); // {}
var z = (_f = ["", "", "", ""], _f.raw = ["", "", "", ""], foo(_f, 1, 2, 3)); // any (with error)
var u = foo(_a || (_a = __getTemplateObject([""], [""]))); // number
var v = foo(_b || (_b = __getTemplateObject(["", ""], ["", ""])), 1); // string
var w = foo(_c || (_c = __getTemplateObject(["", "", ""], ["", "", ""])), 1, 2); // boolean
var x = foo(_d || (_d = __getTemplateObject(["", "", ""], ["", "", ""])), 1, true); // boolean (with error)
var y = foo(_e || (_e = __getTemplateObject(["", "", ""], ["", "", ""])), 1, "2"); // {}
var z = foo(_f || (_f = __getTemplateObject(["", "", "", ""], ["", "", "", ""])), 1, 2, 3); // any (with error)
var _a, _b, _c, _d, _e, _f;
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@ var c = foo2 `${1}`;
var d = foo2([], 1);

//// [taggedTemplateStringsWithOverloadResolution2.js]
var __getTemplateObject = (this && this.__getTemplateObject) || function (cooked, raw) {
if (Object.freeze && Object.defineProperty) {
return Object.freeze(Object.defineProperty(cooked, "raw", { value: Object.freeze(raw) }));
}
cooked.raw = raw;
return cooked;
};
function foo1() {
var stuff = [];
for (var _i = 0; _i < arguments.length; _i++) {
stuff[_i] = arguments[_i];
}
return undefined;
}
var a = (_a = ["", ""], _a.raw = ["", ""], foo1(_a, 1));
var a = foo1(_a || (_a = __getTemplateObject(["", ""], ["", ""])), 1);
var b = foo1([], 1);
function foo2() {
var stuff = [];
Expand All @@ -34,6 +41,6 @@ function foo2() {
}
return undefined;
}
var c = (_b = ["", ""], _b.raw = ["", ""], foo2(_b, 1));
var c = foo2(_b || (_b = __getTemplateObject(["", ""], ["", ""])), 1);
var d = foo2([], 1);
var _a, _b;
Loading

0 comments on commit 587c8a8

Please sign in to comment.