mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-17 15:54:07 +10:00
Dropped underscore functions in favour of UFCS
This commit is contained in:
@@ -3,41 +3,41 @@
|
||||
//test arrays without types
|
||||
var array = [];
|
||||
|
||||
assert _length(array) == 0, "_length failed with array";
|
||||
assert length(array) == 0, "length failed with array";
|
||||
|
||||
_push(array, 1);
|
||||
_push(array, 2);
|
||||
_push(array, 3);
|
||||
_push(array, 4);
|
||||
_push(array, "foo");
|
||||
push(array, 1);
|
||||
push(array, 2);
|
||||
push(array, 3);
|
||||
push(array, 4);
|
||||
push(array, "foo");
|
||||
|
||||
assert _length(array) == 5, "_push failed with array";
|
||||
assert _pop(array) == "foo", "_pop failed with array";
|
||||
assert length(array) == 5, "push failed with array";
|
||||
assert pop(array) == "foo", "pop failed with array";
|
||||
|
||||
_set(array, 2, "bar");
|
||||
assert array == [1, 2, "bar", 4], "_set failed with array";
|
||||
assert _get(array, 3) == 4, "_get failed with array";
|
||||
set(array, 2, "bar");
|
||||
assert array == [1, 2, "bar", 4], "set failed with array";
|
||||
assert get(array, 3) == 4, "get failed with array";
|
||||
|
||||
|
||||
//test dictionaries without types
|
||||
var dict = [:];
|
||||
|
||||
_set(dict, "key", "value");
|
||||
_set(dict, 1, 2);
|
||||
set(dict, "key", "value");
|
||||
set(dict, 1, 2);
|
||||
|
||||
assert dict == ["key":"value", 1:2], "_set failed with dictionaries";
|
||||
assert _get(dict, "key") == "value", "_get failed with dictionaries";
|
||||
assert dict == ["key":"value", 1:2], "set failed with dictionaries";
|
||||
assert get(dict, "key") == "value", "get failed with dictionaries";
|
||||
|
||||
|
||||
//test _length
|
||||
assert _length(array) == 4 && _length(dict) == 2, "_length failed with array or dictionaries";
|
||||
//test length
|
||||
assert length(array) == 4 && length(dict) == 2, "length failed with array or dictionaries";
|
||||
|
||||
|
||||
//test clear
|
||||
_clear(array);
|
||||
_clear(dict);
|
||||
clear(array);
|
||||
clear(dict);
|
||||
|
||||
assert _length(array) == 0 && _length(dict) == 0, "_clear failed with array or dictionaries";
|
||||
assert length(array) == 0 && length(dict) == 0, "clear failed with array or dictionaries";
|
||||
}
|
||||
|
||||
|
||||
@@ -45,46 +45,46 @@
|
||||
//test arrays with types
|
||||
var array: [int] = [];
|
||||
|
||||
assert _length(array) == 0, "_length failed with array (+ types)";
|
||||
assert length(array) == 0, "length failed with array (+ types)";
|
||||
|
||||
_push(array, 1);
|
||||
_push(array, 2);
|
||||
_push(array, 3);
|
||||
_push(array, 4);
|
||||
_push(array, 10);
|
||||
push(array, 1);
|
||||
push(array, 2);
|
||||
push(array, 3);
|
||||
push(array, 4);
|
||||
push(array, 10);
|
||||
|
||||
assert _length(array) == 5, "_push or failed with array (+ types)";
|
||||
assert _pop(array) == 10, "_pop failed with array (+ types)";
|
||||
assert length(array) == 5, "push or failed with array (+ types)";
|
||||
assert pop(array) == 10, "pop failed with array (+ types)";
|
||||
|
||||
_set(array, 2, 70);
|
||||
assert array == [1, 2, 70, 4], "_set failed with array (+ types)";
|
||||
assert _get(array, 3) == 4, "_get failed with array (+ types)";
|
||||
set(array, 2, 70);
|
||||
assert array == [1, 2, 70, 4], "set failed with array (+ types)";
|
||||
assert get(array, 3) == 4, "get failed with array (+ types)";
|
||||
|
||||
|
||||
//test dictionaries with types
|
||||
var dict: [string : string] = [:];
|
||||
|
||||
_set(dict, "key", "value");
|
||||
set(dict, "key", "value");
|
||||
|
||||
assert dict == ["key":"value"], "_set failed with dictionaries (+ types)";
|
||||
assert _get(dict, "key") == "value", "_get failed with dictionaries (+ types)";
|
||||
assert dict == ["key":"value"], "set failed with dictionaries (+ types)";
|
||||
assert get(dict, "key") == "value", "get failed with dictionaries (+ types)";
|
||||
|
||||
|
||||
//test length with types
|
||||
assert _length(array) == 4 && _length(dict) == 1, "_length failed with array or dictionaries (+ types)";
|
||||
assert length(array) == 4 && length(dict) == 1, "length failed with array or dictionaries (+ types)";
|
||||
|
||||
|
||||
//test clear with types
|
||||
_clear(array);
|
||||
_clear(dict);
|
||||
clear(array);
|
||||
clear(dict);
|
||||
|
||||
assert _length(array) == 0 && _length(dict) == 0, "_clear failed with array or dictionaries (+ types)";
|
||||
assert length(array) == 0 && length(dict) == 0, "clear failed with array or dictionaries (+ types)";
|
||||
}
|
||||
|
||||
{
|
||||
var str = "hello world";
|
||||
|
||||
assert _length(str) == 11, "_length failed with string";
|
||||
assert length(str) == 11, "length failed with string";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user