1
0

kernel-checks.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //jshint eqnull:true
  2. define(function () {
  3. "use strict";
  4. function assert (fn) {
  5. try {
  6. if (fn()) return;
  7. } catch (ex) {
  8. throw new Error("Error:\n" + ex + "in assertion:\n" + fn);
  9. }
  10. throw new Error("Assertion failed:\n" + fn);
  11. }
  12. assert(function () {
  13. return !("hasOwnProperty" in Object.create(null));
  14. });
  15. assert(function () {
  16. return new Function("return this")().Object === Object;
  17. });
  18. assert(function () {
  19. return Object.create(new Function("return this")()).Object === Object;
  20. });
  21. assert(function () {
  22. return (function () {
  23. return this;
  24. }).apply(void 0) === void 0;
  25. });
  26. assert(function () {
  27. return (function () {
  28. return this;
  29. }).apply(null) === null;
  30. });
  31. assert(function () {
  32. return (function () {
  33. return this;
  34. }).apply(3) === 3;
  35. });
  36. assert(function () {
  37. return (function () {
  38. return this;
  39. }).apply("foo") === "foo";
  40. });
  41. assert(function () {
  42. return (function () {
  43. return this;
  44. }).apply(true) === true;
  45. });
  46. });