xref: /third_party/decimal.js/test/modules/sign.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/decimal.js/test/modules/
1023dd3b8Sopenharmony_ciif (typeof T === 'undefined') require('../setup');
2023dd3b8Sopenharmony_ci
3023dd3b8Sopenharmony_ciT('sign', function () {
4023dd3b8Sopenharmony_ci
5023dd3b8Sopenharmony_ci  function t(n, expected) {
6023dd3b8Sopenharmony_ci    T.assertEqual(expected, Decimal.sign(n));
7023dd3b8Sopenharmony_ci  }
8023dd3b8Sopenharmony_ci
9023dd3b8Sopenharmony_ci  t(NaN, NaN);
10023dd3b8Sopenharmony_ci  t('NaN', NaN);
11023dd3b8Sopenharmony_ci  t(Infinity, 1);
12023dd3b8Sopenharmony_ci  t(-Infinity, -1);
13023dd3b8Sopenharmony_ci  t('Infinity', 1);
14023dd3b8Sopenharmony_ci  t('-Infinity', -1);
15023dd3b8Sopenharmony_ci
16023dd3b8Sopenharmony_ci  T.assert(1 / Decimal.sign('0') === Infinity);
17023dd3b8Sopenharmony_ci  T.assert(1 / Decimal.sign(new Decimal('0')) === Infinity);
18023dd3b8Sopenharmony_ci  T.assert(1 / Decimal.sign('-0') === -Infinity);
19023dd3b8Sopenharmony_ci  T.assert(1 / Decimal.sign(new Decimal('-0')) === -Infinity);
20023dd3b8Sopenharmony_ci
21023dd3b8Sopenharmony_ci  t('0', 0);
22023dd3b8Sopenharmony_ci  t('-0', -0);
23023dd3b8Sopenharmony_ci  t('1', 1);
24023dd3b8Sopenharmony_ci  t('-1', -1);
25023dd3b8Sopenharmony_ci  t('9.99', 1);
26023dd3b8Sopenharmony_ci  t('-9.99', -1);
27023dd3b8Sopenharmony_ci});
28

Indexes created Thu Nov 07 10:32:03 CST 2024