to-string-tokens.js 857 B

123456789101112131415161718192021222324252627282930313233
  1. /* eslint no-eval: "off" */
  2. "use strict";
  3. module.exports = function (t, a) {
  4. a.deep(
  5. t.call(function (a, b) {
  6. return this[a] + this[b];
  7. }),
  8. { args: "a, b", body: "\n\t\t\treturn this[a] + this[b];\n\t\t" }
  9. );
  10. a.deep(t.call(function () {}), { args: "", body: "" });
  11. // eslint-disable-next-line no-unused-vars
  12. a.deep(t.call(function (raz) {}), { args: "raz", body: "" });
  13. a.deep(
  14. t.call(function () {
  15. Object();
  16. }),
  17. { args: "", body: "\n\t\t\tObject();\n\t\t" }
  18. );
  19. try {
  20. eval("(() => {})");
  21. } catch (e) {
  22. // Non ES2015 env
  23. return;
  24. }
  25. a.deep(t.call(eval("(() => {})")), { args: "", body: "" });
  26. a.deep(t.call(eval("((elo) => foo)")), { args: "elo", body: "foo" });
  27. a.deep(t.call(eval("(elo => foo)")), { args: "elo", body: "foo" });
  28. a.deep(t.call(eval("((elo, bar) => foo())")), { args: "elo, bar", body: "foo()" });
  29. };