mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
REFACTOR: testing module cleanup.
Nesting was unnecessary and added 0 or negative value. So I removed the nesting.
This commit is contained in:
parent
2cefcdbd6a
commit
1b2aa4dfd1
@ -1,4 +1,4 @@
|
||||
let t = import "std/testing.ucg".asserts{};
|
||||
let t = import "std/testing.ucg";
|
||||
|
||||
assert t.equal{
|
||||
left = "hello @" % ("world"),
|
||||
|
@ -1,4 +1,4 @@
|
||||
let t = import "std/testing.ucg".asserts{};
|
||||
let t = import "std/testing.ucg";
|
||||
|
||||
let script = include str "./include_example.sh";
|
||||
assert {
|
||||
|
@ -1,4 +1,4 @@
|
||||
let t = import "std/testing.ucg".asserts{};
|
||||
let t = import "std/testing.ucg";
|
||||
|
||||
let test_empty_mod = module {
|
||||
} => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
let t = import "std/testing.ucg".asserts{};
|
||||
let t = import "std/testing.ucg";
|
||||
|
||||
assert t.ok{
|
||||
test = "foo" is "str",
|
||||
|
@ -1,25 +1,15 @@
|
||||
// A module with helper test assertions for ucg tests.
|
||||
// Each contained module will output a struct with
|
||||
// ok and desc fields.
|
||||
//
|
||||
// ok will be a boolean.
|
||||
// desc will be a descriptive message.
|
||||
let asserts = module{
|
||||
// allows you to specify a a prefix for messages.
|
||||
// specify the prefix to add when the condition is not true.
|
||||
// A default description to use for messages.
|
||||
default_description = "TODO description",
|
||||
} => {
|
||||
let todo_desc = "TODO description";
|
||||
|
||||
// Test that a value is true.
|
||||
let ok = module{
|
||||
// test value expected to be true for success.
|
||||
test=false,
|
||||
// descriptive message to use in output.
|
||||
desc=mod.default_description,
|
||||
} => {
|
||||
let ok = mod.test;
|
||||
desc=todo_desc,
|
||||
} => ({ok=ok, desc=desc}) {
|
||||
assert mod.desc != NULL;
|
||||
|
||||
let ok = mod.test;
|
||||
let desc = "@" % (mod.desc);
|
||||
};
|
||||
|
||||
@ -28,10 +18,11 @@ let asserts = module{
|
||||
// Test value expected to to be false for success.
|
||||
test=true,
|
||||
// descriptive message to use in output.
|
||||
desc=mod.default_description,
|
||||
} => {
|
||||
let ok = not mod.test;
|
||||
desc=todo_desc,
|
||||
} => ({ok=ok, desc=desc}) {
|
||||
assert mod.desc != NULL;
|
||||
|
||||
let ok = not mod.test;
|
||||
let desc = "@" % (mod.desc);
|
||||
|
||||
};
|
||||
@ -43,9 +34,10 @@ let asserts = module{
|
||||
// right value for deep equal comparison.
|
||||
right=NULL,
|
||||
desc="",
|
||||
} => {
|
||||
let ok = mod.left == mod.right;
|
||||
} => ({ok=ok, desc=desc}) {
|
||||
assert mod.desc != NULL;
|
||||
|
||||
let ok = mod.left == mod.right;
|
||||
let desc = select (mod.desc == ""), "@ == @" % (mod.left, mod.right), {
|
||||
false = mod.desc,
|
||||
};
|
||||
@ -58,11 +50,11 @@ let asserts = module{
|
||||
// right value for deep equal comparison.
|
||||
right=NULL,
|
||||
desc="",
|
||||
} => {
|
||||
let ok = mod.left != mod.right;
|
||||
} => ({ok=ok, desc=desc}) {
|
||||
assert mod.desc != NULL;
|
||||
|
||||
let ok = mod.left != mod.right;
|
||||
let desc = select (mod.desc == ""), "@ != @" % (mod.left, mod.right), {
|
||||
false = mod.desc,
|
||||
};
|
||||
};
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
let t = import "std/testing.ucg".asserts{};
|
||||
let t = import "std/testing.ucg";
|
||||
let f = import "std/functional.ucg";
|
||||
|
||||
let op = func (arg) => arg{foo="bar"};
|
||||
|
@ -1,10 +1,8 @@
|
||||
let list = import "std/lists.ucg";
|
||||
let t = import "std/testing.ucg";
|
||||
let asserts = import "std/testing.ucg";
|
||||
|
||||
let list_to_join = [1, 2, 3];
|
||||
|
||||
let asserts = t.asserts{};
|
||||
|
||||
assert asserts.equal{
|
||||
left=list.str_join{sep=",", list=list_to_join},
|
||||
right="1,2,3"
|
||||
|
@ -1,4 +1,4 @@
|
||||
let t = import "std/testing.ucg".asserts{};
|
||||
let t = import "std/testing.ucg";
|
||||
let schema = import "std/schema.ucg";
|
||||
|
||||
assert t.ok{
|
||||
|
@ -1,24 +1,24 @@
|
||||
let strings = import "std/strings.ucg";
|
||||
let t = import "std/testing.ucg".asserts{};
|
||||
let asserts = import "std/testing.ucg";
|
||||
|
||||
let str_class = strings.ops{str="foo bar"};
|
||||
|
||||
assert t.equal{
|
||||
assert asserts.equal{
|
||||
left = str_class.split_on{},
|
||||
right = ["foo", "bar"],
|
||||
};
|
||||
|
||||
assert t.equal{
|
||||
assert asserts.equal{
|
||||
left = strings.ops{str="foo"}.split_on{},
|
||||
right = ["foo"],
|
||||
};
|
||||
|
||||
assert t.equal{
|
||||
assert asserts.equal{
|
||||
left = strings.ops{str=""}.split_on{},
|
||||
right = [""],
|
||||
};
|
||||
|
||||
assert t.equal{
|
||||
assert asserts.equal{
|
||||
left = str_class.split_at(3),
|
||||
right = {left="foo", right=" bar"},
|
||||
};
|
@ -1,6 +1,4 @@
|
||||
let t = import "std/testing.ucg";
|
||||
|
||||
let asserts = t.asserts{};
|
||||
let asserts = import "std/testing.ucg";
|
||||
|
||||
let not_equal_result = asserts.not_equal{
|
||||
left=1,
|
||||
|
@ -1,5 +1,5 @@
|
||||
let tpl = import "std/tuples.ucg";
|
||||
let t = (import "std/testing.ucg").asserts{};
|
||||
let t = (import "std/testing.ucg");
|
||||
|
||||
assert t.equal{
|
||||
left = tpl.fields{tpl={foo=1, bar=2}},
|
||||
|
Loading…
x
Reference in New Issue
Block a user