Skip to content

Commit

Permalink
Merge pull request #2 from monadius/main
Browse files Browse the repository at this point in the history
  • Loading branch information
kazk authored May 3, 2023
2 parents b819d60 + a0a2c33 commit 920b976
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 37 deletions.
55 changes: 30 additions & 25 deletions code_challenge_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1043,31 +1043,36 @@ ocaml:
default: reference
reference:
setup: |-
module Person = struct
type t = { name: string }
let greet (person: t) = (* TODO: write a greeter *)
end
answer: |-
module Person = struct
type t = { name: string }
let greet (person: t) = "Hello, " ^ person.name ^ "!"
end
fixture: |-
module Tests = struct
open OUnit
let suite = [
"Person module" >:::
[
"test_greet" >:: (fun _ ->
let person : Person.t = { Person.name = "Jack" } in
assert_equal "Hello, Jack!" (Person.greet person)
)
]
]
;;
end
let is_even (n: int) = false (* TODO: return true if the number is even *)
let is_odd (n: int) = false (* TODO: return true if the number is odd *)
answer: |-
let is_even (n: int) = n mod 2 = 0
let is_odd (n: int) = n land 1 <> 0
fixture: |-
open OUnit
let suite = [
"is_even tests" >:::
[
"is_even 0" >:: (fun _ ->
assert_equal true (Solution.is_even 0) ~printer:string_of_bool ~msg:"n = 0"
);
"is_even 1" >:: (fun _ ->
assert_equal false (Solution.is_even 1) ~printer:string_of_bool ~msg:"n = 1"
);
];
"is_odd tests" >:::
[
"is_odd 0" >:: (fun _ ->
assert_equal false (Solution.is_odd 0) ~printer:string_of_bool ~msg:"n = 0"
);
"is_even 3" >:: (fun _ ->
assert_equal true (Solution.is_odd 3) ~printer:string_of_bool ~msg:"n = 3"
);
];
]
swift:
default: reference
Expand Down
23 changes: 11 additions & 12 deletions default_fixture_text.toml
Original file line number Diff line number Diff line change
Expand Up @@ -510,21 +510,20 @@ objc = """
ocaml = """
(* TODO: replace with your own tests, these are just how-to examples.
* OUnit Spec example:
* See http://ounit.forge.ocamlcore.org/api-ounit-2.0.0 for documentation
* See https://ocaml.org/p/ounit2/2.2.3/doc/index.html for documentation
* Available packages: https://docs.codewars.com/languages/ocaml
*)
module Tests = struct
open OUnit
let suite = [
"Suite Name" >:::
[
"Test Name" >:: (fun _ ->
assert_equal "Expected" "Actual"
)
]
open Solution
open OUnit
let suite = [
"Suite Name" >:::
[
"Test Name" >:: (fun _ ->
assert_equal "Expected" "Actual" ~printer:Fun.id ~msg:"test"
)
]
;;
end
]
"""

pascal = """
Expand Down

0 comments on commit 920b976

Please sign in to comment.