1
0

kernel-checks.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. assert(function () {
  47. return typeof Promise === "function";
  48. });
  49. assert(function () {
  50. return typeof Promise.resolve === "function";
  51. });
  52. assert(function () {
  53. return typeof Promise.reject === "function";
  54. });
  55. assert(function () {
  56. return typeof new Promise(function () {
  57. }).then === "function";
  58. });
  59. });