First 0.7 update, removing all deprecated features.

This commit is contained in:
Christoffer Lerno
2025-02-27 14:16:36 +01:00
committed by Christoffer Lerno
parent cff6697818
commit 2a895ec7be
1589 changed files with 2635 additions and 115363 deletions

View File

@@ -21,12 +21,12 @@ fn void find_subarray()
fn void concat()
{
int[3] a = { 1, 2, 3 };
free(array::concat_new(a, a));
free(array::concat_new(a[..], a[..]));
free(array::concat_new(a[:0], a[:0]));
free(array::concat_new((int[2]) { 1, 2 }, a[:0]));
free(array::concat_new(a[:0], (int[2]) { 1, 2 }));
int[] c = array::concat_new(a[1..2], a);
free(array::concat(mem, a, a));
free(array::concat(mem, a[..], a[..]));
free(array::concat(mem, a[:0], a[:0]));
free(array::concat(mem, (int[2]) { 1, 2 }, a[:0]));
free(array::concat(mem, a[:0], (int[2]) { 1, 2 }));
int[] c = array::concat(mem, a[1..2], a);
defer free(c);
assert (c == (int[]){ 2, 3, 1, 2, 3 });
}

View File

@@ -4,7 +4,7 @@ const TEST_STRING = "hello world";
fn void test_replace()
{
DString hello = dstring::new("Hello world where are you? Are you here too?");
DString hello = dstring::new(mem, "Hello world where are you? Are you here too?");
defer hello.free();
hello.replace("u", "ooo");
assert(hello.str_view() == "Hello world where are yoooo? Are yoooo here too?");
@@ -51,7 +51,7 @@ fn void test_delete()
fn void test_append()
{
DString str = dstring::new(TEST_STRING);
DString str = dstring::new(mem, TEST_STRING);
defer str.free();
String s;
@@ -105,7 +105,7 @@ fn void test_append()
s = str.str_view();
assert(s == "xxx", "got '%s'; want 'xxx'", s);
DString str2 = dstring::new("yyy");
DString str2 = dstring::new(mem, "yyy");
defer str2.free();
DString str3 = str.concat(mem, str2);
defer str3.free();
@@ -120,7 +120,7 @@ fn void test_append()
fn void test_print()
{
DString str = dstring::new("");
DString str = dstring::new(mem, "");
defer str.free();
String s;
@@ -136,11 +136,11 @@ fn void test_print()
fn void test_copy()
{
DString str = dstring::new(TEST_STRING);
DString str = dstring::new(mem, TEST_STRING);
defer str.free();
String s;
DString str2 = str.copy();
DString str2 = str.copy(mem);
defer str2.free();
s = str2.str_view();
assert(s == TEST_STRING, "got '%s'; want '%s'", s, TEST_STRING);
@@ -148,10 +148,10 @@ fn void test_copy()
fn void test_cmp()
{
DString str = dstring::new(TEST_STRING);
DString str = dstring::new(mem, TEST_STRING);
defer str.free();
DString str2 = dstring::new(TEST_STRING);
DString str2 = dstring::new(mem, TEST_STRING);
defer str2.free();
assert(str.equals(str2));
@@ -164,7 +164,7 @@ fn void test_cmp()
fn void test_join()
{
DString str = dstring::new_join({"hello", "world"}, " ");
DString str = dstring::join(mem, {"hello", "world"}, " ");
defer str.free();
String s = str.str_view();
@@ -173,7 +173,7 @@ fn void test_join()
fn void test_insert_at()
{
DString str = dstring::temp_new(" world");
DString str = dstring::temp(" world");
String s;
str.insert_at(0, "");
@@ -208,7 +208,7 @@ fn void test_insert_at()
fn void test_insert_at_overlaps()
{
DString str = dstring::temp_new("abc");
DString str = dstring::temp("abc");
String s;
String v;
@@ -253,7 +253,7 @@ fn void test_insert_at_overlaps()
fn void test_char_at()
{
DString str = dstring::new("hello");
DString str = dstring::new(mem, "hello");
defer str.free();
char c = str.char_at(1);
@@ -265,7 +265,7 @@ fn void test_char_at()
fn void test_operators()
{
DString str = dstring::new("hello");
DString str = dstring::new(mem, "hello");
defer str.free();
str[0] = 'p';

View File

@@ -14,7 +14,7 @@ fn void test_ref() @test
Foo* f0 = null;
int* a = (void*)(uptr)0x40;
int* b = null;
String s = string::new_format("%s %s %s %s %s", a, b, f0, f, *f);
String s = string::format(mem, "%s %s %s %s %s", a, b, f0, f, *f);
defer free(s);
assert(s == "0x40 0x0 (null) Foo[8] Foo[8]");
}

View File

@@ -12,7 +12,7 @@ struct Bar
{
int x;
int y;
List(<Foo>) foos;
List{Foo} foos;
}
fn void test_new_aligned_compiles() @test

View File

@@ -17,7 +17,7 @@ fn void test_print_null()
ZString z;
int* y;
ZString w = "hello";
String s = string::new_format("%s %s %s", z, w, y);
String s = string::format(mem, "%s %s %s", z, w, y);
defer free(s);
assert(s == "(null) hello 0x0");
}
@@ -96,7 +96,7 @@ fn void test_trim_right()
fn void test_split()
{
String test = "abc|b||c|";
String[] strings = test.split("|");
String[] strings = test.split(mem, "|");
assert(strings.len == 5);
assert(strings[0] == "abc");
assert(strings[1] == "b");
@@ -104,7 +104,7 @@ fn void test_split()
assert(strings[3] == "c");
assert(strings[4] == "");
free(strings);
strings = test.split("|", 2);
strings = test.split(mem, "|", 2);
assert(strings.len == 2);
assert(strings[0] == "abc");
assert(strings[1] == "b||c|");
@@ -114,13 +114,13 @@ fn void test_split()
fn void test_split_skip_empty()
{
String test = "abc|b||c|";
String[] strings = test.split("|", skip_empty: true);
String[] strings = test.split(mem, "|", skip_empty: true);
assert(strings.len == 3);
assert(strings[0] == "abc");
assert(strings[1] == "b");
assert(strings[2] == "c");
free(strings);
strings = test.split("|", 2, skip_empty: true);
strings = test.split(mem, "|", 2, skip_empty: true);
assert(strings.len == 2);
assert(strings[0] == "abc");
assert(strings[1] == "b||c|");
@@ -136,7 +136,7 @@ fn void test_split_to_buffer_skip_empty()
assert(strings[0] == "abc");
assert(strings[1] == "b");
assert(strings[2] == "c");
strings = test.split("|", 2, skip_empty: true);
strings = test.split(mem, "|", 2, skip_empty: true);
assert(strings.len == 2);
assert(strings[0] == "abc");
assert(strings[1] == "b||c|");
@@ -156,7 +156,7 @@ fn void test_split_to_buffer()
assert(strings[4] == "");
String[4] c;
assert(@catch(test.split_to_buffer("|", &c)) == SplitResult.BUFFER_EXCEEDED);
strings = test.split("|", 2);
strings = test.split(mem, "|", 2);
assert(strings.len == 2);
assert(strings[0] == "abc");
assert(strings[1] == "b||c|");