urbit/pkg/arvo/tests/lib/number-to-words.hoon

70 lines
1.6 KiB
Plaintext
Raw Normal View History

2019-02-06 05:59:24 +03:00
:: tests for number-to-words
::
/+ number-to-words, *test
::
|%
++ test-eng-us
=+ eng-us:number-to-words
2019-02-06 05:59:24 +03:00
;: weld
%+ expect-eq
!> `(unit tape)``"zero"
!> (to-words 0)
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!> `(unit tape)``"one"
!> (to-words 1)
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!> `(unit tape)``"twelve"
!> (to-words 12)
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!> `(unit tape)``"twenty"
!> (to-words 20)
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!> `(unit tape)``"ninety-nine"
!> (to-words 99)
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!> `(unit tape)``"one hundred"
!> (to-words 100)
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!> `(unit tape)``"one hundred and eleven"
!> (to-words 111)
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!> `(unit tape)``"one thousand"
!> (to-words 1.000)
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!> `(unit tape)``"one thousand, one hundred and eleven"
!> (to-words 1.111)
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!> `(unit tape)``"one million and one"
!> (to-words 1.000.001)
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!> `(unit tape)``"one trillion"
!> (to-words (pow 10 12))
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!>
^- (unit tape)
:- ~
;: weld
"eighteen quintillion, four hundred and forty-six quadrillion, seven "
"hundred and forty-four trillion, seventy-three billion, seven "
"hundred and nine million, five hundred and fifty-one thousand, six "
"hundred and sixteen"
==
!> (to-words 18.446.744.073.709.551.616)
2019-02-06 05:59:24 +03:00
::
%+ expect-eq
!> `(unit tape)``"one vigintillion"
!> (to-words (pow 10 63))
2019-02-06 05:59:24 +03:00
==
--