$exec may now provide a stdin parameter. Deprecated path.append, path.tappend, getcwd, tgetcwd, path.absolute, ls. Deprecated env::get_config_dir, replaced by env::new_get_config_dir. Added path.has_extension, path.new_append, path.temp_append, new_cwd, temp_cwd, path.new_absolute, new_ls, temp_ls. Added dstring.replace Updated win escapes for exec.

This commit is contained in:
Christoffer Lerno
2024-08-14 00:57:25 +02:00
parent 6bc486400c
commit 3ccb4b9ec3
18 changed files with 309 additions and 145 deletions

View File

@@ -2,6 +2,14 @@ module std::core::dstring2 @test;
const TEST_STRING = "hello world";
fn void test_replace()
{
DString hello = dstring::new("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?");
}
fn void test_delete()
{
{

View File

@@ -5,8 +5,8 @@ fn void! test_dot()
Path p = path::new(".")!;
assert(@catch(p.parent()));
// It must be possible to form the absolute version.
Path p2 = p.absolute()!;
p2 = p.append("/hello/world")!;
Path p2 = p.new_absolute()!;
p2 = p.new_append("/hello/world")!;
if (p2.env == POSIX)
{
assert(p2.str_view() == "hello/world");
@@ -239,6 +239,36 @@ fn void! test_extension()
}
fn void! test_has_extension()
{
assert(!path::new(`C:\temp\foo.bar\README`, .path_env = PathEnv.WIN32)!.has_extension(`bar\README`));
assert(path::new_windows("file.txt")!.has_extension("txt"));
assert(path::new_posix("file.txt")!.has_extension("txt"));
assert(path::new_windows("a/b/file.txt")!.has_extension("txt"));
assert(path::new_posix("a/b/file.txt")!.has_extension("txt"));
assert(path::new_windows("a\\b\\file.txt")!.has_extension("txt"));
assert(path::new_windows("a.b/file.txt")!.has_extension("txt"));
assert(path::new_posix("a.b/file.txt")!.has_extension("txt"));
assert(path::new_windows("a.b/file.txt")!.has_extension("txt"));
assert(path::new_posix("a.b/file.txt")!.has_extension("txt"));
assert(path::new_windows("a.b\\file.txt")!.has_extension("txt"));
assert(path::new_windows("domain.dot.com")!.has_extension("com"));
assert(path::new_posix("domain.dot.com")!.has_extension("com"));
assert(path::new_windows("image.jpeg")!.has_extension("jpeg"));
assert(path::new_posix("image.jpeg")!.has_extension("jpeg"));
assert(path::new_windows("../filename.ext")!.has_extension("ext"));
assert(path::new_posix("../filename.ext")!.has_extension("ext"));
}
fn void! test_basename()
{
assert(path::new_windows("file.txt").basename()! == "file.txt");
@@ -335,7 +365,7 @@ fn void! test_path_absolute()
$if env::WIN32:
assert(path::new_windows(`C:\abs`).absolute()!.str_view() == `C:\abs`);
$else
assert(path::new_posix("/").absolute()!.str_view() == "/");
assert(path::new_posix(".").absolute()!.str_view() == path::getcwd(allocator::temp())!!.str_view());
assert(path::new_posix("/").new_absolute()!.str_view() == "/");
assert(path::new_posix(".").new_absolute()!.str_view() == path::temp_cwd()!!.str_view());
$endif
}