Remove type checking transformation in luaify
This commit is contained in:
@@ -77,13 +77,6 @@ fn local_fn() {
|
||||
}),
|
||||
r#"function(a,b)local function inner(c,d)end;return inner;end"#
|
||||
);
|
||||
assert_eq!(
|
||||
luaify!(|| {
|
||||
fn check(self: string, arg: number) {}
|
||||
inner
|
||||
}),
|
||||
r#"function()local function check(self,arg)do if type(self)=="number"then self=tostring(self);else assert(type(self)=="string","string expected in \'self\', got "..type(self));end;end;do local __arg=arg;arg=tonumber(arg);assert(arg~=nil,"number expected in \'arg\', got "..type(__arg));end;end;return inner;end"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -208,37 +201,6 @@ fn loops() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn type_checks() {
|
||||
assert_eq!(luaify!(|s| {}), r#"function(s)end"#);
|
||||
assert_eq!(
|
||||
luaify!(|s: table| {}),
|
||||
r#"function(s)do assert(type(s)=="table","table expected in \'s\', got "..type(s));end;end"#
|
||||
);
|
||||
assert_eq!(
|
||||
luaify!(|s| { s as string }),
|
||||
r#"function(s)do if type(s)=="number"then s=tostring(s);else assert(type(s)=="string","string expected in \'s\', got "..type(s));end;end;end"#
|
||||
);
|
||||
assert_eq!(
|
||||
luaify!(|s| { s as number }),
|
||||
r#"function(s)do local __s=s;s=tonumber(s);assert(s~=nil,"number expected in \'s\', got "..type(__s));end;end"#
|
||||
);
|
||||
assert_eq!(
|
||||
luaify!(|s| { s as nil }),
|
||||
r#"function(s)do assert(s==nil,"nil expected in \'s\', got "..type(s));end;end"#
|
||||
);
|
||||
assert_eq!(luaify!(|s| { s as any }), r#"function(s)do end;end"#);
|
||||
|
||||
assert_eq!(
|
||||
luaify!(|s| {
|
||||
let (ok, res) = coroutine::r#yield(thread);
|
||||
ok as boolean;
|
||||
res as nil;
|
||||
}),
|
||||
r#"function(s)local ok,res=coroutine.yield(thread);do assert(type(ok)=="boolean","boolean expected in \'ok\', got "..type(ok));end;do assert(res==nil,"nil expected in \'res\', got "..type(res));end;end"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn concat() {
|
||||
assert_eq!(luaify!(concat!(a)), r#"a"#);
|
||||
|
||||
Reference in New Issue
Block a user