| 1 |
"use strict"; |
| 2 |
|
| 3 |
var readFile = require("fs").readFile |
| 4 |
, ast = require("./_ast-function") |
| 5 |
, pg = __dirname + "/__playground"; |
| 6 |
|
| 7 |
module.exports = function (t) { |
| 8 |
return { |
| 9 |
"Normal": function (a, d) { |
| 10 |
readFile(pg + "/function.js", "utf-8", function (err, str) { |
| 11 |
var plainR, astR; |
| 12 |
if (err) { |
| 13 |
d(err); |
| 14 |
return; |
| 15 |
} |
| 16 |
plainR = t("require")(str); |
| 17 |
astR = ast(str, "require"); |
| 18 |
a(plainR.length, astR.length, "Length"); |
| 19 |
astR.forEach(function (val, i) { a.deep(plainR[i], val, i); }); |
| 20 |
d(); |
| 21 |
}); |
| 22 |
}, |
| 23 |
"One character name": function (a, d) { |
| 24 |
readFile(pg + "/function-one-char.js", "utf-8", function (err, str) { |
| 25 |
var plainR, astR; |
| 26 |
if (err) { |
| 27 |
d(err); |
| 28 |
return; |
| 29 |
} |
| 30 |
plainR = t("_")(str); |
| 31 |
astR = ast(str, "_"); |
| 32 |
a(plainR.length, astR.length, "Length"); |
| 33 |
astR.forEach(function (val, i) { a.deep(plainR[i], val, i); }); |
| 34 |
d(); |
| 35 |
}); |
| 36 |
}, |
| 37 |
"Method": function (a, d) { |
| 38 |
readFile(pg + "/method.js", "utf-8", function (err, str) { |
| 39 |
var plainR, astR; |
| 40 |
if (err) { |
| 41 |
d(err); |
| 42 |
return; |
| 43 |
} |
| 44 |
plainR = t("i18n.bind")(str); |
| 45 |
astR = ast(str, "i18n", "bind"); |
| 46 |
a(plainR.length, astR.length, "Length"); |
| 47 |
astR.forEach(function (val, i) { a.deep(plainR[i], val, i); }); |
| 48 |
d(); |
| 49 |
}); |
| 50 |
}, |
| 51 |
"Method as property": function (a, d) { |
| 52 |
readFile(pg + "/method.js", "utf-8", function (err, str) { |
| 53 |
var plainR, astR; |
| 54 |
if (err) { |
| 55 |
d(err); |
| 56 |
return; |
| 57 |
} |
| 58 |
plainR = t("i18n.bind", { asProperty: true })(str); |
| 59 |
astR = ast(str, "i18n", "bind", { asProperty: true }); |
| 60 |
a(plainR.length, astR.length, "Length"); |
| 61 |
astR.forEach(function (val, i) { a.deep(plainR[i], val, i); }); |
| 62 |
d(); |
| 63 |
}); |
| 64 |
} |
| 65 |
}; |
| 66 |
}; |