Skip to content

Conversation

@ingydotnet
Copy link
Contributor

I'm not sure why tests were failing since they pass here: https://github.com/glojurelang/glojure/actions
But this fixed it for me locally and still passing here: https://github.com/ingydotnet/glojure/actions

After this patch:

$ ./bin/linux_amd64/glj test/glojure/test_glojure/numbers.glj

Testing glojure.test-glojure.numbers

Ran 42 tests containing 2744 assertions.
0 failures, 0 errors.

Before this patch:

$ ./bin/linux_amd64/glj test/glojure/test_glojure/numbers.glj

Testing glojure.test-glojure.numbers

FAIL in (nil) (:)
expected: (= vals (map wrapped inputs))
  actual: (not (= [\� \ \ \ \� \� \� \� \�] (\� \ \ \ \� \� \� \ \)))

FAIL in (nil) (:)
expected: (= vals (map wrapped inputs))
  actual: (not (= [255 0 1 127 255 255 255 255 255] (255 0 1 127 255 255 255 0 0)))

FAIL in (nil) (:)
expected: (= vals (map wrapped inputs))
  actual: (not (= [-1 0 1 127 32767 -1 -1 -1 -1] (-1 0 1 127 32767 -1 -1 0 0)))

FAIL in (nil) (:)
expected: (= vals (map wrapped inputs))
  actual: (not (= [-1 0 1 127 32767 2147483647 9223372036854775807 9223372036854775807 9223372036854775807] (-1 0 1 127 32767 2147483647 9223372036854775807 -9223372036854775808 -9223372

FAIL in (nil) (:)
expected: (= vals (map wrapped inputs))
  actual: (not (= [-1 0 1 127 32767 2147483647 9223372036854775807 9223372036854775807 9223372036854775807] (-1 0 1 127 32767 2147483647 9223372036854775807 -9223372036854775808 -9223372

Ran 42 tests containing 2744 assertions.
5 failures, 0 errors.

After this patch:

$ ./bin/linux_amd64/glj test/glojure/test_glojure/numbers.glj

Testing glojure.test-glojure.numbers

Ran 42 tests containing 2744 assertions.
0 failures, 0 errors.

Before this patch:

$ ./bin/linux_amd64/glj test/glojure/test_glojure/numbers.glj

Testing glojure.test-glojure.numbers

FAIL in (nil) (:)
expected: (= vals (map wrapped inputs))
  actual: (not (= [\� \ \ \ \� \� \� \� \�] (\� \ \ \ \� \� \� \ \)))

FAIL in (nil) (:)
expected: (= vals (map wrapped inputs))
  actual: (not (= [255 0 1 127 255 255 255 255 255] (255 0 1 127 255 255 255 0 0)))

FAIL in (nil) (:)
expected: (= vals (map wrapped inputs))
  actual: (not (= [-1 0 1 127 32767 -1 -1 -1 -1] (-1 0 1 127 32767 -1 -1 0 0)))

FAIL in (nil) (:)
expected: (= vals (map wrapped inputs))
  actual: (not (= [-1 0 1 127 32767 2147483647 9223372036854775807 9223372036854775807 9223372036854775807] (-1 0 1 127 32767 2147483647 9223372036854775807 -9223372036854775808 -9223372036854775808)))

FAIL in (nil) (:)
expected: (= vals (map wrapped inputs))
  actual: (not (= [-1 0 1 127 32767 2147483647 9223372036854775807 9223372036854775807 9223372036854775807] (-1 0 1 127 32767 2147483647 9223372036854775807 -9223372036854775808 -9223372036854775808)))

Ran 42 tests containing 2744 assertions.
5 failures, 0 errors.
@ingydotnet ingydotnet requested a review from jfhamlin as a code owner July 26, 2025 21:20
Copy link
Contributor

@jfhamlin jfhamlin left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together! I remember these cases being tricky when I first tried to run this in CI, and that might have been one of the reasons I left my CI PR hanging :). I left a comment with some context and a couple options. Let me know your thoughts on how we can fix this robustly.

STDLIB_TARGETS := $(addprefix pkg/stdlib/glojure/,$(STDLIB:.clj=.glj))

TEST_FILES := $(shell find ./test -name '*.glj')
TEST_FILES := $(shell find ./test -name '*.glj' | sort)
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

[char [:error (char 0) (char 1) (char 127) (char 32767) :error :error :error :error]]
;; In go, char == rune, which is equivalent to int32
[unchecked-char [(Char -1) (Char 0) (Char 1) (Char 127) (Char 32767) (Char math.MaxInt32) (Char -1) (Char -1) (Char -1)]]
[unchecked-char [(Char -1) (Char 0) (Char 1) (Char 127) (Char 32767) (Char math.MaxInt32) (Char -1) (Char 0) (Char 0)]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, for extreme inputs, the behavior turns out to be system-dependent; the unchecked casts intentionally map (nearly) directly to go casts to rune (there's a stop at int64 in-between). These tests are a modified version of Clojure's numbers tests, and on the JVM you can expect consistent behavior. This operation does not behave consistently across systems in Go. For instance, running on my m1 mac, the result is (Char -1).

The right approach here might be one of:

  1. Introduce a new :skip expectation; ignore cases whose expectation is :skip. Leave comments with reasoning.
  2. Support system-dependent expectations

2 is interesting, but there's no great way to be exhaustive. 1 seems adequate. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly I just wanted to not see the failures for these when running make test. Now I don't and the CI is green.

I'd be fine with just disabling these tests for now. Maybe comment them out with TODO text explaining why.

BTW, I'm close to submitting a PR that fixes issues with basic sort and sort-by. Just adding more tests.

I'm in the Clojure slack, if you want to chat more easily :)

@jfhamlin
Copy link
Contributor

jfhamlin commented Aug 3, 2025

Slightly different fix merged in #80

@jfhamlin jfhamlin closed this Aug 3, 2025
@ingydotnet ingydotnet deleted the fix-numbers-tests branch September 25, 2025 19:58
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.

2 participants