Skip to content

Compare stdlib functions to OCaml - #2973

Merged
pbiggar merged 75 commits into
mainfrom
paul/fuzz-fns
Mar 14, 2021
Merged

pbiggar merged 75 commits into
mainfrom
paul/fuzz-fns

Conversation

@pbiggar

@pbiggar pbiggar commented Mar 13, 2021

Copy link
Copy Markdown
Member

Though we had many implementation of the stdlib functions in F#, I hadn't tested them against the OCaml implementations to make sure there was no unchanged behaviour.

I added an API to run Dark code in the OCaml implementation and to compare the output to the Dark implementation. I hooked it up to the fuzzer and also to the existing unit tests. Then I went through all the existing functions and made sure the results were the same, occasionally fixing bugs in the F# implementation and adding notes about next steps once the F# implementation ships.

While I made as much bug-for-bug compatible as possible, I did aim to make error messages identical.

Fixes:

  • error message on Date::parse
  • support % for Int::mod
  • string.replace works when the argument is ""
  • Date functions now give negative dates for before 1970, like the OCaml versions
  • fix String.toInt around the 2^62 boundary
  • fix signature of Int::remainder
  • implement List::contains and List::member, with tests
  • remove List::all as it's not in the OCaml version
  • fix tests of Int::random
  • handle NaNs, and different ordering of parameters, in Int::Clamp
  • add list tests
  • make the implementation of Record creation identical to OCaml
  • make the implementation of List creation identical to OCaml
  • fix List::head_v2, List::tail_v0
  • don't check list length on List::last_v0
  • implement DB:: queryOneWithExactFields::v0 and DB:::generateKey
  • normalize strings when they are created (fixes a lot of "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" tests)
  • fix String::random_v2 signature, and add many more random tests
  • fix String::first and add simpler implementation
  • add many many string tests
  • fix String::slice which has some edge cases
  • fix String.split which has lots and lots of edge cases
  • fix String::toUppercase and String::toLowercase
  • fix String::slugify_v{0,1,2} and add lots of tests
  • fix String::replaceAll
  • Port String::base64Decode

Other changes:

  • ported the type checker
  • improve error message on incorrect arguments
  • support other arguments in scripts/run-fsharp-tests
  • port AST traversals
  • normalize arguments between implementations by parsing the OCaml exception messages
  • remove old README
  • add support for FSHARPONLY and OCAMLONLY tests (mostly to add two implementations for different error messages)
  • support sending userfunction parameters to OCaml
  • add all the Test functions to OCaml
  • split the OCaml libraries so that the backend libraries are not in libbackend anymore
  • rename libserialization to libocaml
  • add Test::inspect
  • add execution functions to be used in the fsi
  • add Test::toChar

@pbiggar
pbiggar merged commit a949d19 into main Mar 14, 2021
@pbiggar
pbiggar deleted the paul/fuzz-fns branch March 14, 2021 14:20
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.

1 participant