Commit a6d97593 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Replace debugging calculator with unit tests

parent c00a3772
......@@ -10,19 +10,9 @@
<body>
<h1>Belenios Tool</h1>
<div id="calculator">
<h2>Calculator</h2>
<h2>Unit tests</h2>
<div>
<textarea id="calc_a" rows="1" cols="40"></textarea>
<textarea id="calc_b" rows="1" cols="40"></textarea>
</div>
<div>
<button id="do_add">Add</button>
<button id="do_mul">Multiply</button>
<button id="do_sub">Subtract</button>
</div>
<div>
<textarea id="calc_r" rows="1" cols="80" readonly="readonly">
</textarea>
<button id="do_unit_tests">Run unit tests</button>
</div>
</div>
<div id="tkeygen">
......
......@@ -61,28 +61,12 @@ let set_textarea id z =
(fun x -> x##value <- Js.string z)
)
module Calc = struct
module Tests = struct
let add () =
let a = Z.of_string (get_textarea "calc_a") in
let b = Z.of_string (get_textarea "calc_b") in
set_textarea "calc_r" Z.(to_string (a + b))
let unit_tests () =
alert "All tests were successful!"
let mul () =
let a = Z.of_string (get_textarea "calc_a") in
let b = Z.of_string (get_textarea "calc_b") in
set_textarea "calc_r" Z.(to_string (a * b))
let sub () =
let a = Z.of_string (get_textarea "calc_a") in
let b = Z.of_string (get_textarea "calc_b") in
set_textarea "calc_r" Z.(to_string (a - b))
let cmds = [
"do_add", add;
"do_mul", mul;
"do_sub", sub;
]
let cmds = ["do_unit_tests", unit_tests]
end
module Tkeygen = struct
......@@ -98,7 +82,7 @@ module Tkeygen = struct
let cmds = ["do_tkeygen", tkeygen]
end
let cmds = Calc.cmds @ Tkeygen.cmds
let cmds = Tests.cmds @ Tkeygen.cmds
let install_handlers () =
List.iter install_handler cmds
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment