Skip to content

Add darts #539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add darts #539

wants to merge 1 commit into from

Conversation

BNAndras
Copy link
Member

No description provided.

@georgyo
Copy link
Member

georgyo commented Apr 15, 2025

Looks pretty good to me!

Do you want to take a stab at creating a test generator for this one?

@georgyo georgyo requested a review from Copilot April 15, 2025 11:03
Copilot

This comment was marked as resolved.

@BNAndras
Copy link
Member Author

I'm having trouble running test_gen even though I have a local copy of problem specifications (see bottom).

My current template adapted from knapsack seems to get most of the way, but I manually converted the integral X and Y values into floats for simplicity. Is there a way I can reflect that in the template?

open Base
open OUnit2
open Darts

let ae exp got _test_ctxt =
  let printer = Int.to_string in
  assert_equal exp got ~printer

let tests = [
{{#cases}}
    "{{description}}" >::
    ae {{#input}}{{expected}} ({{property}} ({{x}}) ({{y}})){{/input}};
{{/cases}}
]

let () =
  run_test_tt_main ("darts tests" >::: tests)

Error message

Leaving directory '/home/anagy/Documents/GitHub/exercism-ocaml/test-generator'
Uncaught exception:                
  
  (Unix.Unix_error "No such file or directory" opendir
   "((dirname ./problem-specifications/exercises))")

Raised at Core_unix.improve in file "core_unix/src/core_unix.ml", line 45, characters 4-83
Called from Generator__Files.ls_dir in file "lib_generator/files.ml", line 22, characters 7-30
Called from Generator__Files.find_files in file "lib_generator/files.ml", lines 51-52, characters 2-11
Called from Generator__Controller.run in file "lib_generator/controller.ml", line 15, characters 4-73
Called from Dune__exe__Test_gen.command.(fun) in file "bin_test_gen/test_gen.ml", lines 42-47, characters 11-26
Called from Command.For_unix.run.(fun) in file "command/src/command.ml", lines 3388-3399, characters 8-31
Called from Base__Exn.handle_uncaught_aux in file "src/exn.ml", line 126, characters 6-10```

@kahgoh
Copy link
Member

kahgoh commented Apr 16, 2025

I think we could format the X and Y into floats by "editing" the cases in test-generator/lib_generator/special_cases.ml. I remember having to "edit" data to format the list of items in the knapsack PR #525 (the edit_knapsnack function). Let us know if you need further help.

@kahgoh
Copy link
Member

kahgoh commented May 2, 2025

Hey @BNAndras, just thought to ask how are you going with the handling the floats with template? Would you like me to have a look at it?

@BNAndras
Copy link
Member Author

BNAndras commented May 3, 2025

I've been dealing with family matters this week, but I can probably work on it later this week. The major issue is that I can't run the test generator at the moment (see up-thread) so I can't confirm what the generated tests look like.

@kahgoh
Copy link
Member

kahgoh commented May 4, 2025

Ok, no worries 😉

I just looked at the exception again and realized it says it can't find ./problem-specifications/exercises. I wonder if you missed the git submodule update --init --recursive step? (There is a problem-specifications Git submodule in the OCaml repository)

@BNAndras
Copy link
Member Author

BNAndras commented May 4, 2025

I was following the building section instructions, which didn't reference that. dune build ./bin_test_gen --profile=release works though after running your command. The built test_gen executable works up to forth, which should be fine in this case. However, test-generator/README.md doesn't give guidance on how to deal with special cases. It seems the intention is for me to add code to edit the incoming problem-specs JSON before it goes into the darts template.. So I should add an entry to edit_parameters for this slug since I want to update the x and y parameters. Then I handle how to to turn the ints into floats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants