-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(p12) add dune's settings and tests for tailrec
- Loading branch information
Showing
8 changed files
with
113 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
*.annot | ||
*.cmo | ||
*.cma | ||
*.cmi | ||
*.a | ||
*.o | ||
*.cmx | ||
*.cmxs | ||
*.cmxa | ||
|
||
# ocamlbuild working directory | ||
_build/ | ||
|
||
# ocamlbuild targets | ||
*.byte | ||
*.native | ||
|
||
# oasis generated files | ||
setup.data | ||
setup.log | ||
|
||
# Merlin configuring file for Vim and Emacs | ||
.merlin | ||
|
||
# Dune generated files | ||
*.install | ||
|
||
# Local OPAM switch | ||
_opam/ |
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,4 @@ | ||
(executable | ||
(public_name p12) | ||
(name main) | ||
(libraries p12_lib)) |
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 @@ | ||
let () = print_endline "Hello, World!" |
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,23 @@ | ||
(lang dune 3.16) | ||
|
||
(name p12) | ||
|
||
(generate_opam_files true) | ||
|
||
(source | ||
(github pmpknu/fp-lab1)) | ||
|
||
(authors "Dan Gorlyakov") | ||
|
||
|
||
(license MIT) | ||
|
||
; (documentation https://url/to/documentation) | ||
|
||
(package | ||
(name p12) | ||
(synopsis "fp lab1") | ||
(description "two tasks for the first lab for fp course at itmo") | ||
(depends ocaml dune) | ||
) | ||
|
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,4 @@ | ||
(library | ||
(name p12_lib) | ||
(modules iterative map module rec tailrec) | ||
) |
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,28 @@ | ||
# This file is generated by dune, edit dune-project instead | ||
opam-version: "2.0" | ||
synopsis: "fp lab1" | ||
description: "two tasks for the first lab for fp course at itmo" | ||
authors: ["Dan Gorlyakov"] | ||
license: "MIT" | ||
homepage: "https://github.com/pmpknu/fp-lab1" | ||
bug-reports: "https://github.com/pmpknu/fp-lab1/issues" | ||
depends: [ | ||
"ocaml" | ||
"dune" {>= "3.16"} | ||
"odoc" {with-doc} | ||
] | ||
build: [ | ||
["dune" "subst"] {dev} | ||
[ | ||
"dune" | ||
"build" | ||
"-p" | ||
name | ||
"-j" | ||
jobs | ||
"@install" | ||
"@runtest" {with-test} | ||
"@doc" {with-doc} | ||
] | ||
] | ||
dev-repo: "git+https://github.com/pmpknu/fp-lab1.git" |
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,3 @@ | ||
(test | ||
(name test_p12) | ||
(libraries p12_lib ounit2)) |
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,21 @@ | ||
open OUnit2 | ||
open P12_lib | ||
|
||
(* Tailrec tests *) | ||
let test_tailrec_count_factors _ = | ||
OUnit2.assert_equal 6 (Tailrec.count_factors_tail 28); | ||
OUnit2.assert_equal 9 (Tailrec.count_factors_tail 36); | ||
OUnit2.assert_equal 0 (Tailrec.count_factors_tail 0) | ||
|
||
let test_tailrec_find_triangular _ = | ||
OUnit2.assert_equal 28 (Tailrec.find_triangular_with_divisors_tail 5); | ||
OUnit2.assert_equal 76576500 (Tailrec.find_triangular_with_divisors_tail 500) | ||
|
||
let suite = | ||
"Project Euler Problem 12 Tests" >::: [ | ||
"Tailrec - count_factors" >:: test_tailrec_count_factors; | ||
"Tailrec - find_triangular" >:: test_tailrec_find_triangular; | ||
] | ||
|
||
let _ = run_test_tt_main suite | ||
|