46 Commits

Author SHA1 Message Date
metagn
334848f3ae fix regression with enum types wrongly matching [backport:2.2] (#25010)
fixes #25009

Introduced by #24176, when matching a set type to another, if the given
set is a constructor and the element types match worse than a generic
match (which includes the case with no match), the match is always set
to a convertible match, without checking that it is at least a
convertible match. This is fixed by checking this.
2025-06-21 23:25:04 +02:00
ringabout
42a4adb4a5 fixes #24941; missing < (less than), cmp for cstring (#24942)
fixes #24941

now `cmp` can select the correct version of cstring comparsions
2025-05-10 08:26:21 +02:00
metagn
7dfadb8b4e stricter set type match, implicit conversion for literals (#24176)
fixes #18396, fixes #20142

Set types with base types matching less than a generic match (so
subrange matches, conversion matches, int conversion matches) are now
considered mismatching, as their representation is different on the
backends (except VM and JS), causing codegen issues. An exception is
granted for set literal types, which now implicitly convert each element
to the matched base type, so things like `s == {'a', 'b'}` are still
possible where `s` is `set[range['a'..'z']]`. Also every conversion
match in this case is unified under the normal "conversion" match, so a
literal doesn't match one set type better than the other, unless it's
equal.

However `{'a', 'b'} == s` or `{'a', 'b'} - s` etc is now not possible.
when it used to work in the VM. So this is somewhat breaking, and needs
a changelog entry.
2024-10-03 20:39:55 +02:00
metagn
b7b1313d21 proper error message for out-of-range enum sets (#24027)
fixes #17848
2024-08-29 16:13:06 +02:00
ringabout
3bdb531f90 fixes testament targets field (#23472) 2024-04-03 11:33:56 +08:00
ringabout
4b6a9e4add fixes #23422; card regression (#23437)
fixes #23422

ref https://github.com/nim-lang/Nim/issues/20997
https://github.com/nim-lang/Nim/pull/21165

The function `cardSet` is used for large sets that are stored in the
form of arrays. It shouldn't be passed as a pointer
2024-03-28 11:04:47 +01:00
Juan M Gómez
4937aa952b adds another pass for sets fixes #6259 (#22099)
* adds another pass for sets fixes #6259

* Update tsets.nim

removes extra `#`
2023-06-15 18:50:00 +02:00
metagn
b97d603cd0 some test cleanups & category reorganization (#22010)
* clean up some test categories

* mention exact slice issue

* magics into system

* move trangechecks into overflow

* move tmemory to system

* try fix CI

* try fix CI

* final CI fix
2023-06-06 06:54:07 +02:00
Bung
d76458a6cd add test for #13764 (#21699) 2023-04-21 18:05:50 +08:00
metagn
b0a98cc01e warn on set types bigger than max size, default to 0..255 for int literals (#21659)
* test implicitly huge set types

refs https://github.com/nim-lang/RFCs/issues/298

* oh my god

* boot at least

* don't error, fix remaining issues, no 2 len arrays

* fix runnable example

* test assuming 0..255 for int literal

* test refactor, add changelog, test
2023-04-17 20:55:22 +02:00
Bung
0b319fee3d fix #20997 calling system.card[T](x: set[T]) with T of int8 or uint8 … (#21010)
* fix #20997 calling system.card[T](x: set[T]) with T of int8 or uint8 uses mismatched C array sizes
* fullfil set variant
2022-12-23 12:20:25 +01:00
metagn
5ebd1248df overloadable enums no longer experimental (#20298)
depends on #20126
2022-09-05 23:38:38 +02:00
Kaushal Modi
539bced70d Add test for issue 15435 (#19079)
* Add test for issue 15435

Closes https://github.com/nim-lang/Nim/issues/15435.

* Specify bug # in comment

Addresses https://github.com/nim-lang/Nim/pull/19079#discussion_r740279547
2021-11-03 06:46:34 +01:00
Timothee Cour
0dc534832e close #16123 std/sets with closures in cpp (#17921)
* close #16123 std/sets with closures in cpp

* fixup
2021-05-03 07:07:31 +02:00
Timothee Cour
198b5e3a7a improve tsets.nim, twrong_setconstr.nim and avoid name clashes with compiler sets (#17876)
* improve tests/sets/tsets.nim and avoid name clashes with compiler sets
* avoid name clashes in twrong_setconstr.nim and merge into tsets
2021-04-29 13:53:58 +02:00
flywind
3f56b9944e follow up #17536 (#17727) 2021-04-15 19:25:03 +02:00
flywind
d3705b253c close #5792 with testcase (#17536) 2021-03-27 10:18:35 -07:00
Miran
40a5d6537a fix #17385, len must be declared before items (#17386) 2021-03-15 10:45:10 -07:00
flywind
8873ec6084 fix #17076 (#17081) 2021-02-18 06:59:58 +01:00
flywind
6d442a40a6 use doAssert in tests (#16486) 2020-12-28 14:13:21 +01:00
Timothee Cour
42dad3a836 tables/sharedtables/intsets/etc: fix #13496, #13504, #13505; add lots of tests (#13498) [backport]
* fix #13496 handle tombstones
* add test
* more tests
* fix #13504; add SharedTable tests
* fix #https://github.com/nim-lang/Nim/issues/13505 intsets.missingOrExcl silently gave wrong results sometimes
* add test for tintsets
2020-02-26 22:07:09 +01:00
Andy Davidoff
d208d7a995 set[T].len is an alias for set[T].card (#11885) [feature] 2019-08-05 14:27:45 +02:00
Miran
43832f8e57 remove shadow warning, fixes #10732 (#11039) 2019-04-17 11:54:51 +02:00
Arne Döring
1105d03644 require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
Araq
6279b0587a make tests green again 2018-11-16 19:54:49 +01:00
Miran
1b17c9f693 More descriptive names of test files (#9531)
* change generic `tissues` name to more specific
* change `tvarious` to more specific names
2018-10-29 17:07:27 +01:00
Miran
749dbce4c6 Merge tests into a larger file (part 5 of ∞) (#9368)
* merge magics

* merge metatype tests

* merge method tests

* merge objects tests

* change `import future` to `import sugar`

Nim in Action tests are left with `import future`, to ensure compatibility.

* merge overload tests

* merge proc tests

* merge procvar tests

* merge range tests

* merge seq tests

* merge sets tests

* remove wrong assert from `tsets3`

* fix `jsTests`

* better fix
2018-10-16 10:50:10 +02:00
Araq
96c6c82d55 fixes #8425 2018-08-04 20:10:03 +02:00
skilchen
8fe8bed9c3 add sets.pop procedure (analogue to python) (#8383) 2018-07-21 19:51:14 +02:00
LemonBoy
0a14b3d198 Check the RHS when building a set (#8159)
Fixes #2669
2018-06-30 09:16:14 +02:00
Oscar Nihlgård
427490a845 Fix compile time set cardinality (#7558) 2018-04-10 10:38:16 +02:00
superfunc
d1f6ddfd64 Add counterpart to containsOrIncl for excl (#6360) 2017-09-15 10:49:32 +02:00
Adam Strzelecki
e80465dacf tests: Trim .nim files trailing whitespace
via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
2015-09-04 23:04:32 +02:00
patrick dw
69e15ac32f renamed writeln to writeLine in tests 2015-06-19 01:34:34 -05:00
Araq
26eae7d00e fixes #2470, fixes #1354 2015-04-28 20:21:53 +02:00
def
54d61d2f66 Add TSet difference tests 2014-07-15 02:16:12 +02:00
Felix Krause
ac3f872fa3 Fixed TSet proc names to conform with set 2014-06-26 20:55:46 +02:00
Felix Krause
bdd3b6c612 Added logical set operations to TSet 2014-06-25 22:07:28 +02:00
Dominik Picheta
2fb5d62927 Tester now appreciates the test target. Modified 'cmd' in specs. 2014-04-16 21:28:19 +01:00
Clay Sweetser
ce5a494927 Changed tests and tools to use 'discard' statements instead of 'nil' for empty blocks. 2014-02-15 18:57:03 -05:00
Simon Hafner
56c41ae140 added tests for set 2014-02-10 12:45:00 -06:00
Simon Hafner
0779d96a83 moved the tests for TSet to the correct place 2014-02-09 17:04:00 -06:00
Simon Hafner
6fda10aed0 added test specs for the tester 2014-02-01 18:39:39 -06:00
Simon Hafner
9f29bb8d9e corrected docs and tests 2014-02-01 16:07:44 -06:00
Simon Hafner
2c5a2d07fb sets equivalence 2014-01-31 18:22:27 -06:00
Araq
20b5f31c03 new tester; all tests categorized 2014-01-13 02:10:03 +01:00