polyfills.tests.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * @author TristanVALCKE / https://github.com/Itee
  3. */
  4. /* global QUnit */
  5. import '../../../src/polyfills';
  6. import { Vector3 } from '../../../src/math/Vector3';
  7. export default QUnit.module( 'Polyfills', () => {
  8. // PUBLIC STUFF
  9. QUnit.todo( "Number.EPSILON", ( assert ) => {
  10. assert.ok( false, "everything's gonna be alright" );
  11. } );
  12. QUnit.todo( "Number.isInteger", ( assert ) => {
  13. assert.ok( false, "everything's gonna be alright" );
  14. } );
  15. //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
  16. //http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.sign
  17. /*
  18. 20.2.2.29 Math.sign(x)
  19. Returns the sign of the x, indicating whether x is positive, negative or zero.
  20. If x is NaN, the result is NaN.
  21. If x is -0, the result is -0.
  22. If x is +0, the result is +0.
  23. If x is negative and not -0, the result is -1.
  24. If x is positive and not +0, the result is +1.
  25. */
  26. QUnit.test( "Math.sign", ( assert ) => {
  27. assert.ok( isNaN( Math.sign( NaN ) ), "If x is NaN<NaN>, the result is NaN." );
  28. assert.ok( isNaN( Math.sign( new Vector3() ) ), "If x is NaN<object>, the result is NaN." );
  29. assert.ok( isNaN( Math.sign() ), "If x is NaN<undefined>, the result is NaN." );
  30. assert.ok( isNaN( Math.sign( '--3' ) ), "If x is NaN<'--3'>, the result is NaN." );
  31. assert.ok( isNegativeZero( Math.sign( - 0 ) ), "If x is -0, the result is -0." );
  32. assert.ok( Math.sign( + 0 ) === + 0, "If x is +0, the result is +0." );
  33. assert.ok( Math.sign( - Infinity ) === - 1, "If x is negative<-Infinity> and not -0, the result is -1." );
  34. assert.ok( Math.sign( '-3' ) === - 1, "If x is negative<'-3'> and not -0, the result is -1." );
  35. assert.ok( Math.sign( '-1e-10' ) === - 1, "If x is negative<'-1e-10'> and not -0, the result is -1." );
  36. assert.ok( Math.sign( + Infinity ) === + 1, "If x is positive<+Infinity> and not +0, the result is +1." );
  37. assert.ok( Math.sign( '+3' ) === + 1, "If x is positive<'+3'> and not +0, the result is +1." );
  38. // Comparing with -0 is tricky because 0 === -0. But
  39. // luckily 1 / -0 === -Infinity so we can use that.
  40. function isNegativeZero( value ) {
  41. return value === 0 && 1 / value < 0;
  42. }
  43. } );
  44. QUnit.todo( "'name' in Function.prototype", ( assert ) => {
  45. assert.ok( false, "everything's gonna be alright" );
  46. } );
  47. QUnit.todo( "Object.assign", ( assert ) => {
  48. assert.ok( false, "everything's gonna be alright" );
  49. } );
  50. } );