test: prove ordinary import binding modes
This commit is contained in:
@@ -17,19 +17,19 @@ import path;
|
||||
let i: i32 = 0;
|
||||
for (i < 4) {
|
||||
let got: i32 = 0;
|
||||
if (abs(ins[i])) { got = 1; };
|
||||
if (path.abs(ins[i])) { got = 1; };
|
||||
assert(!(got != want[i]));
|
||||
i += 1;
|
||||
};
|
||||
|
||||
// buffer-arm: &buf ptr-ident-widens into the union.
|
||||
let buf = buffer { ... };
|
||||
assert(!(abs(&buf))); // empty → false
|
||||
assert(!(push(&buf, "/foo")! != "/foo"));
|
||||
assert(!(!abs(&buf))); // "/foo" → true
|
||||
let buf: path.buffer;
|
||||
assert(!(path.abs(&buf))); // empty → false
|
||||
assert(!(path.push(&buf, "/foo")! != "/foo"));
|
||||
assert(!(!path.abs(&buf))); // "/foo" → true
|
||||
buf.end = 0;
|
||||
assert(!(push(&buf, "foo")! != "foo"));
|
||||
assert(!(abs(&buf))); // "foo" → false
|
||||
assert(!(path.push(&buf, "foo")! != "foo"));
|
||||
assert(!(path.abs(&buf))); // "foo" → false
|
||||
};
|
||||
|
||||
// ref/hare/path/buffer.ha:44-51. Both arms: str (== sepstr) and *buffer
|
||||
@@ -37,24 +37,24 @@ import path;
|
||||
// inline; str-arm rows table-driven.
|
||||
|
||||
@test fn isroot_cases() void = {
|
||||
let buf = buffer { ... };
|
||||
let buf: path.buffer;
|
||||
// empty buffer (end 0)
|
||||
assert(!(isroot(&buf)));
|
||||
assert(!(path.isroot(&buf)));
|
||||
|
||||
// "/" — root. local() is c3, so seed the SEP byte directly.
|
||||
buf.buf[0] = SEP; buf.end = 1;
|
||||
assert(!(!isroot(&buf)));
|
||||
assert(!(string(&buf) != "/"));
|
||||
buf.buf[0] = path.SEP; buf.end = 1;
|
||||
assert(!(!path.isroot(&buf)));
|
||||
assert(!(path.string(&buf) != "/"));
|
||||
|
||||
// "foo" — relative, not root.
|
||||
buf.end = 0;
|
||||
assert(!(push(&buf, "foo")! != "foo"));
|
||||
assert(!(isroot(&buf)));
|
||||
assert(!(path.push(&buf, "foo")! != "foo"));
|
||||
assert(!(path.isroot(&buf)));
|
||||
|
||||
// "/foo" — absolute but not root.
|
||||
buf.buf[0] = SEP; buf.end = 1;
|
||||
assert(!(push(&buf, "foo")! != "/foo"));
|
||||
assert(!(isroot(&buf)));
|
||||
buf.buf[0] = path.SEP; buf.end = 1;
|
||||
assert(!(path.push(&buf, "foo")! != "/foo"));
|
||||
assert(!(path.isroot(&buf)));
|
||||
|
||||
// str-arm (buffer.ha:47): only the bare separator is root.
|
||||
let ins: [4]str;
|
||||
@@ -66,7 +66,7 @@ import path;
|
||||
let i: i32 = 0;
|
||||
for (i < 4) {
|
||||
let got: i32 = 0;
|
||||
if (isroot(ins[i])) { got = 1; };
|
||||
if (path.isroot(ins[i])) { got = 1; };
|
||||
assert(!(got != want[i]));
|
||||
i += 1;
|
||||
};
|
||||
@@ -76,10 +76,10 @@ import path;
|
||||
// buffer views the byte prefix.
|
||||
|
||||
@test fn string_cases() void = {
|
||||
let buf = buffer { ... };
|
||||
assert(!(string(&buf) != "."));
|
||||
assert(!(push(&buf, "foo")! != "foo"));
|
||||
assert(!(string(&buf) != "foo"));
|
||||
let buf: path.buffer;
|
||||
assert(!(path.string(&buf) != "."));
|
||||
assert(!(path.push(&buf, "foo")! != "foo"));
|
||||
assert(!(path.string(&buf) != "foo"));
|
||||
};
|
||||
|
||||
// ref/hare/path/buffer.ha:55-77. Rewrites '/'→SEP into a static buffer;
|
||||
@@ -95,7 +95,7 @@ import path;
|
||||
ins[3]=""; want[3]="";
|
||||
let i: i32 = 0;
|
||||
for (i < 4) {
|
||||
assert(!(local(ins[i])! != want[i]));
|
||||
assert(!(path.local(ins[i])! != want[i]));
|
||||
i += 1;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user