Skip to content
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

Fix creation of float arrays #113

Merged
merged 3 commits into from
Oct 24, 2024
Merged

Fix creation of float arrays #113

merged 3 commits into from
Oct 24, 2024

Conversation

vouillon
Copy link
Collaborator

Fixes #112.

@rickyvetter
Copy link
Contributor

Tested this locally and it works well. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offering a slighly more thorough test that also covers the getter and setter code paths:

let construct x = [| x |]

let get (x : float array) = x.(0)
let get_ (x : _ array) = x.(0)

let set (x : float array) e = x.(0) <- e
let set_ (x : _ array) e = x.(0) <- e

let a = construct 1.0

let _ = set a 2.0

let _ = assert (Float.equal (get a) 2.0)
let _ = assert (Float.equal (get_ a) 2.0)

let _ = set_ a 3.0

let _ = assert (Float.equal (get a) 3.0)
let _ = assert (Float.equal (get_ a) 3.0)

let b = [| 1.0 |]

let _ = set b 2.0

let _ = assert (Float.equal (get b) 2.0)
let _ = assert (Float.equal (get_ b) 2.0)

let _ = set_ b 3.0

let _ = assert (Float.equal (get b) 3.0)
let _ = assert (Float.equal (get_ b) 3.0)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@vouillon vouillon merged commit c1390f7 into main Oct 24, 2024
28 checks passed
@vouillon vouillon deleted the caml-make-array branch October 24, 2024 19:11
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.

[BUG] float array error
2 participants