This Rust-based tool generates, compiles, and tests code using LLMs, resolves dependencies, and provides explanations of existing code through embeddings.
open OUnit2
open Solution
let test1 _ =
assert_equal 3 (solution 1 2)
let test2 _ =
assert_equal (-3) (solution (-1) (-2))
(* OCaml is statically typed, so adding a string and an integer is not allowed.
Therefore, this test case is omitted or can be used to demonstrate type safety. *)
let suite =
"solution_tests" >::: [
"test1" >:: test1;
"test2" >:: test2;
(* "test3" >:: test3; *)
]
let () =
run_test_tt_main suite
Launch example
Example query:
Example generation:
dune-project
solution.opam
src/solution.ml
test/solution_test.ml
dune
Example install dependencies
Example build project
Example run tests
=====
Explanation of the Steps:
Create Folder and Copy Files:
ocaml
.logic.md
andprompt.txt
files into theocaml
directory.Launch Command:
rustsn
tool with the--lang=ocaml
flag to initialize an OCaml project based on your query.Project Structure:
solution
that adds two integers.solution
function.Installing Dependencies:
opam install . --deps-only
to install all necessary dependencies defined in thesolution.opam
file.Building the Project:
dune build
to compile the OCaml project.Running Tests:
dune runtest
to execute the unit tests and verify the functionality of thesolution
function.