-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
481 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(***********************************************************************) | ||
(* *) | ||
(* OCaml *) | ||
(* *) | ||
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) | ||
(* *) | ||
(* Copyright 1996 Institut National de Recherche en Informatique et *) | ||
(* en Automatique. All rights reserved. This file is distributed *) | ||
(* under the terms of the GNU Library General Public License, with *) | ||
(* the special exception on linking described in file ../LICENSE. *) | ||
(* *) | ||
(***********************************************************************) | ||
(* Adapted significantly by Authors of BuckleScript *) | ||
|
||
|
||
(** {!Belt.Float} | ||
Utililites for Float | ||
*) | ||
|
||
external toInt: float -> int = "%intoffloat" | ||
|
||
external fromInt: int -> float = "%identity" | ||
|
||
external fromString: string -> float = "parseFloat" [@@bs.val] | ||
|
||
external toString: float -> string = "String" [@@bs.val] | ||
|
||
let (+) = (+.) | ||
|
||
let (-) = (-.) | ||
|
||
let (/) = (/.) | ||
|
||
let ( * ) = ( *. ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(***********************************************************************) | ||
(* *) | ||
(* OCaml *) | ||
(* *) | ||
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) | ||
(* *) | ||
(* Copyright 1996 Institut National de Recherche en Informatique et *) | ||
(* en Automatique. All rights reserved. This file is distributed *) | ||
(* under the terms of the GNU Library General Public License, with *) | ||
(* the special exception on linking described in file ../LICENSE. *) | ||
(* *) | ||
(***********************************************************************) | ||
(* Adapted significantly by Authors of BuckleScript *) | ||
|
||
|
||
(** {!Belt.Float} | ||
Utililites for Float | ||
*) | ||
|
||
external toInt: float -> int = "%intoffloat" | ||
|
||
external fromInt: int -> float = "%identity" | ||
|
||
external fromString: string -> float = "parseFloat" [@@bs.val] | ||
|
||
external toString: float -> string = "String" [@@bs.val] | ||
|
||
val (+): float -> float -> float | ||
|
||
val (-): float -> float -> float | ||
|
||
val (/): float -> float -> float | ||
|
||
val ( * ): float -> float -> float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(***********************************************************************) | ||
(* *) | ||
(* OCaml *) | ||
(* *) | ||
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) | ||
(* *) | ||
(* Copyright 1996 Institut National de Recherche en Informatique et *) | ||
(* en Automatique. All rights reserved. This file is distributed *) | ||
(* under the terms of the GNU Library General Public License, with *) | ||
(* the special exception on linking described in file ../LICENSE. *) | ||
(* *) | ||
(***********************************************************************) | ||
(* Adapted significantly by Authors of BuckleScript *) | ||
|
||
|
||
(** {!Belt.Int} | ||
Utililites for Int | ||
*) | ||
|
||
external toFloat: int -> float = "%identity" | ||
|
||
external fromFloat: float -> int = "%intoffloat" | ||
|
||
external fromString: string -> (_ [@bs.as 10]) -> int = "parseInt" [@@bs.val] | ||
|
||
external toString: int -> string = "String" [@@bs.val] | ||
|
||
let (+) = (+) | ||
|
||
let (-) = (-) | ||
|
||
let (/) = (/) | ||
|
||
let ( * ) = ( * ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(***********************************************************************) | ||
(* *) | ||
(* OCaml *) | ||
(* *) | ||
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) | ||
(* *) | ||
(* Copyright 1996 Institut National de Recherche en Informatique et *) | ||
(* en Automatique. All rights reserved. This file is distributed *) | ||
(* under the terms of the GNU Library General Public License, with *) | ||
(* the special exception on linking described in file ../LICENSE. *) | ||
(* *) | ||
(***********************************************************************) | ||
(* Adapted significantly by Authors of BuckleScript *) | ||
|
||
|
||
(** {!Belt.Int} | ||
Utililites for Int | ||
*) | ||
|
||
external toFloat: int -> float = "%identity" | ||
|
||
external fromFloat: float -> int = "%intoffloat" | ||
|
||
external fromString: string -> (_ [@bs.as 10]) -> int = "parseInt" [@@bs.val] | ||
|
||
external toString: int -> string = "String" [@@bs.val] | ||
|
||
val (+): int -> int -> int | ||
|
||
val (-): int -> int -> int | ||
|
||
val (/): int -> int -> int | ||
|
||
val ( * ): int -> int -> int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
'use strict'; | ||
|
||
var Mt = require("./mt.js"); | ||
var Block = require("../../lib/js/block.js"); | ||
|
||
var suites = /* record */[/* contents : [] */0]; | ||
|
||
var test_id = /* record */[/* contents */0]; | ||
|
||
function eq(loc, x, y) { | ||
return Mt.eq_suites(test_id, suites, loc, x, y); | ||
} | ||
|
||
function b(loc, x) { | ||
return Mt.bool_suites(test_id, suites, loc, x); | ||
} | ||
|
||
function $$throw(loc, x) { | ||
return Mt.throw_suites(test_id, suites, loc, x); | ||
} | ||
|
||
function neq(loc, x, y) { | ||
test_id[0] = test_id[0] + 1 | 0; | ||
suites[0] = /* :: */[ | ||
/* tuple */[ | ||
loc + (" id " + String(test_id[0])), | ||
(function (param) { | ||
return /* Neq */Block.__(1, [ | ||
x, | ||
y | ||
]); | ||
}) | ||
], | ||
suites[0] | ||
]; | ||
return /* () */0; | ||
} | ||
|
||
eq("File \"bs_float_test.ml\", line 14, characters 5-12", 1, 1.0); | ||
|
||
eq("File \"bs_float_test.ml\", line 15, characters 5-12", -1, -1.0); | ||
|
||
eq("File \"bs_float_test.ml\", line 18, characters 5-12", 1, 1); | ||
|
||
eq("File \"bs_float_test.ml\", line 19, characters 5-12", 1, 1); | ||
|
||
eq("File \"bs_float_test.ml\", line 20, characters 5-12", 1, 1); | ||
|
||
eq("File \"bs_float_test.ml\", line 21, characters 5-12", -1, -1); | ||
|
||
eq("File \"bs_float_test.ml\", line 22, characters 5-12", -1, -1); | ||
|
||
eq("File \"bs_float_test.ml\", line 23, characters 5-12", -1, -1); | ||
|
||
eq("File \"bs_float_test.ml\", line 26, characters 5-12", parseFloat("1"), 1.0); | ||
|
||
eq("File \"bs_float_test.ml\", line 27, characters 5-12", parseFloat("-1"), -1.0); | ||
|
||
eq("File \"bs_float_test.ml\", line 28, characters 5-12", parseFloat("1.7"), 1.7); | ||
|
||
eq("File \"bs_float_test.ml\", line 29, characters 5-12", parseFloat("-1.0"), -1.0); | ||
|
||
eq("File \"bs_float_test.ml\", line 30, characters 5-12", parseFloat("-1.5"), -1.5); | ||
|
||
eq("File \"bs_float_test.ml\", line 31, characters 5-12", parseFloat("-1.7"), -1.0); | ||
|
||
eq("File \"bs_float_test.ml\", line 34, characters 5-12", String(1.0), "1"); | ||
|
||
eq("File \"bs_float_test.ml\", line 35, characters 5-12", String(-1.0), "-1"); | ||
|
||
eq("File \"bs_float_test.ml\", line 36, characters 5-12", String(-1.5), "-1.5"); | ||
|
||
eq("File \"bs_float_test.ml\", line 40, characters 5-12", 2.0 + 3.0, 5.0); | ||
|
||
eq("File \"bs_float_test.ml\", line 41, characters 5-12", 2.0 - 3.0, -1.0); | ||
|
||
eq("File \"bs_float_test.ml\", line 42, characters 5-12", 2.0 * 3.0, 6.0); | ||
|
||
eq("File \"bs_float_test.ml\", line 43, characters 5-12", 3.0 / 2.0, 1.5); | ||
|
||
Mt.from_pair_suites("File \"bs_float_test.ml\", line 45, characters 23-30", suites[0]); | ||
|
||
var F = 0; | ||
|
||
exports.suites = suites; | ||
exports.test_id = test_id; | ||
exports.eq = eq; | ||
exports.b = b; | ||
exports.$$throw = $$throw; | ||
exports.neq = neq; | ||
exports.F = F; | ||
/* Not a pure module */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
let suites : Mt.pair_suites ref = ref [] | ||
let test_id = ref 0 | ||
let eq loc x y = Mt.eq_suites loc x y ~test_id ~suites | ||
let b loc x = Mt.bool_suites loc x ~test_id ~suites | ||
let throw loc x = Mt.throw_suites ~test_id ~suites loc x | ||
let neq loc x y = | ||
incr test_id ; | ||
suites := | ||
(loc ^" id " ^ (string_of_int !test_id), (fun _ -> Mt.Neq(x,y))) :: !suites | ||
|
||
module F = Belt.Float | ||
|
||
let () = | ||
eq __LOC__ (F.fromInt 1) 1.0; | ||
eq __LOC__ (F.fromInt (-1)) (-1.0) | ||
|
||
let () = | ||
eq __LOC__ (F.toInt 1.0) 1; | ||
eq __LOC__ (F.toInt 1.3) 1; | ||
eq __LOC__ (F.toInt 1.7) 1; | ||
eq __LOC__ (F.toInt (-1.0)) (-1); | ||
eq __LOC__ (F.toInt (-1.5)) (-1); | ||
eq __LOC__ (F.toInt (-1.7)) (-1) | ||
|
||
let () = | ||
eq __LOC__ (F.fromString "1") 1.0; | ||
eq __LOC__ (F.fromString "-1") (-1.0); | ||
eq __LOC__ (F.fromString "1.7") 1.7; | ||
eq __LOC__ (F.fromString "-1.0") (-1.0); | ||
eq __LOC__ (F.fromString "-1.5") (-1.5); | ||
eq __LOC__ (F.fromString "-1.7") (-1.0) | ||
|
||
let () = | ||
eq __LOC__ (F.toString 1.0) "1"; | ||
eq __LOC__ (F.toString (-1.0)) "-1"; | ||
eq __LOC__ (F.toString (-1.5)) "-1.5" | ||
|
||
let () = | ||
let open F in | ||
eq __LOC__ (2.0 + 3.0) 5.0; | ||
eq __LOC__ (2.0 - 3.0) (-1.0); | ||
eq __LOC__ (2.0 * 3.0) 6.0; | ||
eq __LOC__ (3.0 / 2.0) 1.5; | ||
|
||
;; Mt.from_pair_suites __LOC__ !suites |
Oops, something went wrong.