mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
First 0.7 update, removing all deprecated features.
This commit is contained in:
committed by
Christoffer Lerno
parent
cff6697818
commit
2a895ec7be
@@ -4,9 +4,9 @@ import std::collections::growablebitset;
|
||||
import std::collections::list;
|
||||
import std::io;
|
||||
|
||||
def List = List(<usz>);
|
||||
def List = List{usz};
|
||||
|
||||
def BitSet = BitSet(<2048>);
|
||||
def BitSet = BitSet{2048};
|
||||
|
||||
fn void set_get()
|
||||
{
|
||||
@@ -24,7 +24,6 @@ fn void set_get()
|
||||
assert(bs.cardinality() == 2);
|
||||
|
||||
List found;
|
||||
found.tinit();
|
||||
foreach (i, x : bs)
|
||||
{
|
||||
switch (i)
|
||||
@@ -46,7 +45,7 @@ fn void set_get()
|
||||
assert(bs.cardinality() == 0);
|
||||
}
|
||||
|
||||
def GrowableBitSet = GrowableBitSet(<char>);
|
||||
def GrowableBitSet = GrowableBitSet{char};
|
||||
fn void growable_set_get()
|
||||
{
|
||||
GrowableBitSet bs;
|
||||
@@ -68,7 +67,6 @@ fn void growable_set_get()
|
||||
assert(bs.len() == 2001, "Len should be 2001");
|
||||
|
||||
List found;
|
||||
found.tinit();
|
||||
foreach (i, x : bs)
|
||||
{
|
||||
switch (i)
|
||||
|
||||
@@ -2,7 +2,7 @@ module test;
|
||||
import std::io;
|
||||
import std::collections::map;
|
||||
|
||||
def IntMap = HashMap(<String, int>);
|
||||
def IntMap = HashMap{String, int};
|
||||
fn void copy_map() @test
|
||||
{
|
||||
TrackingAllocator alloc;
|
||||
@@ -43,9 +43,8 @@ fn void copy_keys() @test
|
||||
@pool()
|
||||
{
|
||||
IntMap x;
|
||||
x.tinit();
|
||||
x.set("hello", 0); // keys copied into temp hashmap
|
||||
y = x.copy_keys(allocator::heap()); // keys copied out
|
||||
y = x.keys(mem); // keys copied out
|
||||
// end of pool: hashmap and its copied-in keys dropped
|
||||
};
|
||||
assert(y == {"hello"});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module elastic_array_test @test;
|
||||
import std::collections::elastic_array;
|
||||
|
||||
def IntList = ElasticArray(<int, 10>);
|
||||
def PtrList = ElasticArray(<void*, 10>);
|
||||
def IntList = ElasticArray{int, 10};
|
||||
def PtrList = ElasticArray{void*, 10};
|
||||
|
||||
fn void delete_contains_index()
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ enum FooEnum
|
||||
THREE,
|
||||
}
|
||||
|
||||
def FooEnumMap = EnumMap(<FooEnum, uint>);
|
||||
def FooEnumMap = EnumMap{FooEnum, uint};
|
||||
|
||||
fn void enums()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module linkedlist_test @test;
|
||||
import std::collections::linkedlist;
|
||||
|
||||
def IntList = LinkedList(<int>);
|
||||
def IntList = LinkedList{int};
|
||||
|
||||
fn void test_push_front()
|
||||
{
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
module list_test @test;
|
||||
import std::collections::list;
|
||||
|
||||
def IntList = List(<int>);
|
||||
def PtrList = List(<void*>);
|
||||
def IntList = List{int};
|
||||
def PtrList = List{void*};
|
||||
|
||||
struct Overalign
|
||||
{
|
||||
float[<4>] x @align(128);
|
||||
}
|
||||
|
||||
def OveralignList = List(<Overalign>);
|
||||
def OveralignList = List{Overalign};
|
||||
fn void overaligned_type()
|
||||
{
|
||||
OveralignList l;
|
||||
@@ -24,7 +24,6 @@ fn void overaligned_type()
|
||||
fn void delete_contains_index()
|
||||
{
|
||||
IntList test;
|
||||
defer test.free();
|
||||
|
||||
test.add_array({ 1, 2 });
|
||||
assert(test.contains(1));
|
||||
@@ -55,7 +54,6 @@ fn void delete_contains_index()
|
||||
fn void compact()
|
||||
{
|
||||
PtrList test;
|
||||
defer test.free();
|
||||
test.add_array({ null, &test });
|
||||
assert(test.compact_count() == 1);
|
||||
test.push(null);
|
||||
@@ -69,7 +67,6 @@ fn void compact()
|
||||
fn void reverse()
|
||||
{
|
||||
IntList test;
|
||||
defer test.free();
|
||||
|
||||
test.reverse();
|
||||
test.add_array({ 1, 2 });
|
||||
@@ -86,7 +83,6 @@ fn void reverse()
|
||||
fn void remove_if()
|
||||
{
|
||||
IntList test;
|
||||
defer test.free();
|
||||
usz removed;
|
||||
|
||||
test.add_array({ 1, 11, 2, 10, 20 });
|
||||
@@ -104,8 +100,8 @@ fn void remove_if()
|
||||
fn void init_with_array()
|
||||
{
|
||||
IntList foo;
|
||||
defer foo.free();
|
||||
foo.init_with_array(mem, { 1, 2, 3});
|
||||
defer foo.free();
|
||||
assert(foo.len() == 3);
|
||||
assert(foo[2] == 3);
|
||||
}
|
||||
@@ -121,7 +117,6 @@ fn void init_with_temp_array()
|
||||
fn void remove_using_test()
|
||||
{
|
||||
IntList test;
|
||||
defer test.free();
|
||||
usz removed;
|
||||
|
||||
test.add_array({ 1, 11, 2, 10, 20 });
|
||||
@@ -139,7 +134,6 @@ fn void remove_using_test()
|
||||
fn void retain_if()
|
||||
{
|
||||
IntList test;
|
||||
defer test.free();
|
||||
usz removed;
|
||||
|
||||
test.add_array({ 1, 11, 2, 10, 20 });
|
||||
@@ -157,7 +151,6 @@ fn void retain_if()
|
||||
fn void retain_using_test()
|
||||
{
|
||||
IntList test;
|
||||
defer test.free();
|
||||
usz removed;
|
||||
|
||||
test.add_array({ 1, 11, 2, 10, 20 });
|
||||
|
||||
@@ -4,15 +4,14 @@ import std::collections::map;
|
||||
import std::sort;
|
||||
import std::io;
|
||||
|
||||
def TestHashMap = HashMap(<String, usz>);
|
||||
def TestMap = Map(<String, usz>);
|
||||
def TestHashMap = HashMap{String, usz};
|
||||
|
||||
struct MapTest
|
||||
{
|
||||
String key;
|
||||
usz value;
|
||||
}
|
||||
def List = List(<MapTest>);
|
||||
def List = List{MapTest};
|
||||
|
||||
fn void map()
|
||||
{
|
||||
@@ -56,7 +55,7 @@ fn void map()
|
||||
}
|
||||
}
|
||||
|
||||
def FooMap = HashMap(<char, Foobar>);
|
||||
def FooMap = HashMap{char, Foobar};
|
||||
enum Foobar : inline char
|
||||
{
|
||||
FOO,
|
||||
@@ -103,13 +102,4 @@ fn void map_copy()
|
||||
|
||||
assert(hash_map_copy.len() == hash_map.len());
|
||||
|
||||
TestMap map = map::temp(<String, usz>)();
|
||||
|
||||
map.set("aa", 1);
|
||||
map.set("b", 2);
|
||||
map.set("bb", 1);
|
||||
|
||||
TestMap map_copy = map::temp_from_map(<String, usz>)(map);
|
||||
|
||||
assert(map_copy.len() == map.len());
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ fn void test_to_format_int()
|
||||
{
|
||||
Object* int_object = object::new_int(16, allocator::heap());
|
||||
defer int_object.free();
|
||||
String s = string::new_format("%s", int_object);
|
||||
String s = string::format(mem, "%s", int_object);
|
||||
defer free(s);
|
||||
assert(s == "16");
|
||||
}
|
||||
{
|
||||
Object* int_object = object::new_int(-16, allocator::heap());
|
||||
defer int_object.free();
|
||||
String s = string::new_format("%s", int_object);
|
||||
String s = string::format(mem, "%s", int_object);
|
||||
defer free(s);
|
||||
assert(s == "-16");
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ module priorityqueue_test @test;
|
||||
import std::collections;
|
||||
import std::collections::priorityqueue;
|
||||
|
||||
def Queue = PriorityQueue(<int>);
|
||||
def Queue = PriorityQueue{int};
|
||||
|
||||
fn void priorityqueue()
|
||||
{
|
||||
@@ -32,7 +32,7 @@ fn void priorityqueue()
|
||||
assert(x == 3, "got %d; want %d", x, 3);
|
||||
}
|
||||
|
||||
def QueueMax = PriorityQueueMax(<int>);
|
||||
def QueueMax = PriorityQueueMax{int};
|
||||
|
||||
fn void priorityqueue_max()
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module range_test @test;
|
||||
import std::collections::range;
|
||||
|
||||
def IntRange = Range(<int>);
|
||||
def IntExRange = ExclusiveRange(<int>);
|
||||
def IntRange = Range{int};
|
||||
def IntExRange = ExclusiveRange{int};
|
||||
|
||||
fn void test_range()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ module ringbuffer_test @test;
|
||||
import std::collections::ringbuffer;
|
||||
import std::io;
|
||||
|
||||
def Buffer = RingBuffer(<char, 4>);
|
||||
def Buffer = RingBuffer{char[4]};
|
||||
|
||||
fn void push_get()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user