Files
c3c/test/unit/stdlib/collections/anylist.c3
Christoffer Lerno e605a21fd3 Revert "Revert 0.7.6 code for 0.7.5 re-release"
This reverts commit d1349c9cfb.
2025-09-05 23:30:35 +02:00

29 lines
605 B
Plaintext

module anylist_test @test;
import std::collections::anylist;
fn void pop() => @pool()
{
AnyList l;
l.push(1.0);
l.push(1);
l.push("hello");
assert(l.pop(String)!! == "hello");
assert(l.pop(int)!! == 1);
assert(l.copy_pop(tmem)!!.type == double.typeid);
}
fn void predicates() => @pool()
{
AnyList l;
l.push(123u);
l.push(-1);
l.push("abc");
l.push(5.0);
l.remove_using_test(fn (x, p) => x.type == p.type, &&456u);
assert(l[0].type == int.typeid);
assert(l.get(0, int)!! == -1);
l.retain_if(fn (x) => x.type == double.typeid);
assert(l.len() == 1);
assert(l.get(0, double)!! == 5.0);
}