Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
belenios
belenios
Commits
a6d97593
Commit
a6d97593
authored
May 23, 2014
by
Stephane Glondu
Browse files
Replace debugging calculator with unit tests
parent
c00a3772
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/tool/belenios_tool.html
View file @
a6d97593
...
...
@@ -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"
>
...
...
src/tool/tool_js.ml
View file @
a6d97593
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment