Skip to content

builtin: fix tests for int#24528

Merged
spytheman merged 1 commit into
vlang:masterfrom
lcheylus:tests-builtin_int
May 20, 2025
Merged

builtin: fix tests for int#24528
spytheman merged 1 commit into
vlang:masterfrom
lcheylus:tests-builtin_int

Conversation

@lcheylus

@lcheylus lcheylus commented May 20, 2025

Copy link
Copy Markdown
Contributor

In test_str_methods, cast numbers with voidptr first.


Tests OK on Linux (Debian/testing amd64) with prod mode.

  • Before fix
$ ./v -stats -prod test vlib/builtin/int_test.v
---- Testing... ----
vlib/builtin/int_test.v:32:10: error: cannot cast a number to a type reference, use `nil` or a voidptr cast first: `&Type(voidptr(123))`
   30 |     assert voidptr(-1).str() == '0xffffffffffffffff'
   31 |     assert voidptr(1).str() == '0x1'
   32 |     assert (&u8(-1)).str() == 'ffffffffffffffff'
      |             ~~~~~~~
   33 |     assert (&u8(1)).str() == '1'
   34 |     assert byteptr(-1).str() == '0xffffffffffffffff'
vlib/builtin/int_test.v:33:10: error: cannot cast a number to a type reference, use `nil` or a voidptr cast first: `&Type(voidptr(123))`
   31 |     assert voidptr(1).str() == '0x1'
   32 |     assert (&u8(-1)).str() == 'ffffffffffffffff'
   33 |     assert (&u8(1)).str() == '1'
      |             ~~~~~~
   34 |     assert byteptr(-1).str() == '0xffffffffffffffff'
   35 |     assert byteptr(1).str() == '0x1'
checker summary: 2 V errors, 0 V warnings, 0 V notices

----
  • With fix
$ ./v -stats -prod test vlib/builtin/int_test.v
---- Testing... ----
        V  source  code size:      30118 lines,     139255 tokens,     808034 bytes,   288 types,    12 modules,   133 files
generated  target  code size:      15188 lines,     609296 bytes
compilation took: 6168.986 ms, compilation speed: 4882 vlines/s, cgen threads: 7
running tests in: /home/fox/dev/vlang.git/vlib/builtin/int_test.v
      OK    [ 1/18]     0.000 ms     4 asserts | main.test_const()
      OK    [ 2/18]     0.005 ms    25 asserts | main.test_str_methods()
      OK    [ 3/18]     0.001 ms     6 asserts | main.test_and_precedence()
      OK    [ 4/18]     0.000 ms     6 asserts | main.test_or_precedence()
      OK    [ 5/18]     0.000 ms     6 asserts | main.test_xor_precedence()
      OK    [ 6/18]     0.000 ms     2 asserts | main.test_left_shift_precedence()
      OK    [ 7/18]     0.000 ms     2 asserts | main.test_right_shift_precedence()
0
7
6
      OK    [ 8/18]     0.000 ms     1 assert  | main.test_i8_print()
      OK    [ 9/18]     0.000 ms     1 assert  | main.test_int_alias()
      OK    [10/18]     0.001 ms    13 asserts | main.test_hex()
      OK    [11/18]     0.001 ms     8 asserts | main.test_bin()
      OK    [12/18]     0.000 ms     9 asserts | main.test_oct()
      OK    [13/18]     0.000 ms    11 asserts | main.test_num_separator()
      OK    [14/18]     0.000 ms     6 asserts | main.test_int_decl()
      OK    [15/18]     0.010 ms    31 asserts | main.test_int_to_hex()
      OK    [16/18]     0.000 ms     3 asserts | main.test_repeat()
      OK    [17/18]     0.000 ms     8 asserts | main.test_int_min()
      OK    [18/18]     0.000 ms     8 asserts | main.test_int_max()
     Summary for running V tests in "int_test.v": 150 passed, 150 total. Elapsed time: 0 ms.

 OK    6183.743 ms vlib/builtin/int_test.v
----
Summary for all V _test.v files: 1 passed, 1 total. Elapsed time: 6184 ms, on 1 job. Comptime: 0 ms. Runtime: 6183 ms.

In test_str_methods, cast numbers with voidptr first.

Signed-off-by: Laurent Cheylus <foxy@free.fr>
@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22896

@spytheman spytheman merged commit 35d33ff into vlang:master May 20, 2025
74 checks passed
@lcheylus lcheylus deleted the tests-builtin_int branch May 20, 2025 13:09
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