mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
switched typeof for oftype, switched typeas for astype
This commit is contained in:
@@ -72,7 +72,7 @@ print [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
|
||||
var x = 31;
|
||||
var y : int = 42;
|
||||
var arr : [int] = [1, 2, 3, 42];
|
||||
var dict : [string, int] = ["hello": 1, "world":2];
|
||||
var dict : [string:int] = ["hello": 1, "world":2];
|
||||
|
||||
//printing expressions
|
||||
print x;
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
|
||||
|
||||
var t: type = typeas [int];
|
||||
var u: type = typeas [t];
|
||||
var t: type = astype [int];
|
||||
var u: type = astype [t];
|
||||
|
||||
var a: u;
|
||||
|
||||
t = typeas [float]; //redefnition
|
||||
t = astype [float]; //redefnition
|
||||
|
||||
var b: u;
|
||||
|
||||
print typeof a; //<[<int>]>
|
||||
print typeof b; //<[<float>]>
|
||||
print oftype a; //<[<int>]>
|
||||
print oftype b; //<[<float>]>
|
||||
@@ -32,7 +32,7 @@
|
||||
assert func() == 69, "import/export of functions failed";
|
||||
}
|
||||
|
||||
//test that variables retain their types with the typeof keyword
|
||||
//test that variables retain their types with the oftype keyword
|
||||
{
|
||||
var t: type = int;
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
{
|
||||
import t;
|
||||
|
||||
assert typeof t == type, "type retention failed";
|
||||
assert oftype t == type, "type retention failed";
|
||||
}
|
||||
|
||||
print "All good";
|
||||
|
||||
@@ -7,15 +7,15 @@ assert u == 42, "first-class types are screwing with values";
|
||||
|
||||
|
||||
//differentiate by the "type" value
|
||||
var v: type = typeas [int];
|
||||
var v: type = astype [int];
|
||||
var w = [int];
|
||||
var x = v;
|
||||
|
||||
assert w == [int], "defining an array of types failed";
|
||||
assert x == typeas [int], "re-assigning a type value failed";
|
||||
assert x == astype [int], "re-assigning a type value failed";
|
||||
|
||||
//complex type
|
||||
var complex: type = typeas [string : [int]];
|
||||
var complex: type = astype [string : [int]];
|
||||
var dict: complex = [
|
||||
"first array": [1, 2, 3],
|
||||
"second array": [4, 5, 6],
|
||||
|
||||
Reference in New Issue
Block a user