tests/pass/frexp.lua

Sat, 21 Sep 2013 14:31:22 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 21 Sep 2013 14:31:22 +0100
changeset 143
a689e0187ef5
parent 142
574e0baea136
permissions
-rw-r--r--

Fix math.frexp() and add more tests (thanks Florob, Link Mauve, xnyhps)

142
574e0baea136 Add math.frexp() and tests (many thanks to Florob and Link Mauve!)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 local m, e = math.frexp(1);
574e0baea136 Add math.frexp() and tests (many thanks to Florob and Link Mauve!)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 assert(m == 0.5 and e == 1, "frexp(1)");
574e0baea136 Add math.frexp() and tests (many thanks to Florob and Link Mauve!)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
574e0baea136 Add math.frexp() and tests (many thanks to Florob and Link Mauve!)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local m, e = math.frexp(0);
574e0baea136 Add math.frexp() and tests (many thanks to Florob and Link Mauve!)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 assert(m == 0 and e == 0, "frexp(0)");
574e0baea136 Add math.frexp() and tests (many thanks to Florob and Link Mauve!)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6
574e0baea136 Add math.frexp() and tests (many thanks to Florob and Link Mauve!)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 local m, e = math.frexp(3);
574e0baea136 Add math.frexp() and tests (many thanks to Florob and Link Mauve!)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 assert(m == 0.75 and e == 2, "frexp(3)");
574e0baea136 Add math.frexp() and tests (many thanks to Florob and Link Mauve!)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9
574e0baea136 Add math.frexp() and tests (many thanks to Florob and Link Mauve!)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 local m, e = math.frexp(-1);
143
a689e0187ef5 Fix math.frexp() and add more tests (thanks Florob, Link Mauve, xnyhps)
Matthew Wild <mwild1@gmail.com>
parents: 142
diff changeset
11 assert(m == -0.5 and e == 1, "frexp(-1)");
a689e0187ef5 Fix math.frexp() and add more tests (thanks Florob, Link Mauve, xnyhps)
Matthew Wild <mwild1@gmail.com>
parents: 142
diff changeset
12
a689e0187ef5 Fix math.frexp() and add more tests (thanks Florob, Link Mauve, xnyhps)
Matthew Wild <mwild1@gmail.com>
parents: 142
diff changeset
13 local m, e = math.frexp(0.5);
a689e0187ef5 Fix math.frexp() and add more tests (thanks Florob, Link Mauve, xnyhps)
Matthew Wild <mwild1@gmail.com>
parents: 142
diff changeset
14 assert(m == 0.5 and e == 0, "frexp(0.5)");
a689e0187ef5 Fix math.frexp() and add more tests (thanks Florob, Link Mauve, xnyhps)
Matthew Wild <mwild1@gmail.com>
parents: 142
diff changeset
15
a689e0187ef5 Fix math.frexp() and add more tests (thanks Florob, Link Mauve, xnyhps)
Matthew Wild <mwild1@gmail.com>
parents: 142
diff changeset
16 local m, e = math.frexp(0.1);
a689e0187ef5 Fix math.frexp() and add more tests (thanks Florob, Link Mauve, xnyhps)
Matthew Wild <mwild1@gmail.com>
parents: 142
diff changeset
17 assert(m == 0.8 and e == -3, "frexp(0.1)");

mercurial