Add raw! and embed! macros in luaify
This commit is contained in:
@@ -10,6 +10,12 @@ fn raw_ident() {
|
||||
assert_eq!(luaify!(r#mut::r#ref()), r#"mut.ref()"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn escape() {
|
||||
assert_eq!(luaify!("\nmy\tstring\x00a"), r#""\nmy\tstring\x00a""#);
|
||||
assert_eq!(luaify!(r#" "raw string" "#), r#"" \"raw string\" ""#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn indexing() {
|
||||
assert_eq!(luaify!(table.0), r#"table[0]"#);
|
||||
@@ -274,18 +280,15 @@ fn ops() {
|
||||
assert_eq!(luaify!(|| a / b), r#"function()return a/b;end"#);
|
||||
assert_eq!(luaify!(|| a /= b), r#"function()a=a/b;end"#);
|
||||
assert_eq!(luaify!(|| a = b % c), r#"function()a=math.fmod(b,c);end"#);
|
||||
assert_eq!(luaify!(|| a = b << c), r#"function()a=bit.lshift(b,c);end"#);
|
||||
assert_eq!(luaify!(|| a = b << c), r#"function()a=lshift(b,c);end"#);
|
||||
assert_eq!(
|
||||
luaify!(|| a <<= b << c),
|
||||
r#"function()a=bit.lshift(a,bit.lshift(b,c));end"#
|
||||
);
|
||||
assert_eq!(
|
||||
luaify!(|| a = b >> c),
|
||||
r#"function()a=bit.arshift(b,c);end"#
|
||||
r#"function()a=lshift(a,lshift(b,c));end"#
|
||||
);
|
||||
assert_eq!(luaify!(|| a = b >> c), r#"function()a=arshift(b,c);end"#);
|
||||
assert_eq!(
|
||||
luaify!(|| a >>= b >> c),
|
||||
r#"function()a=bit.arshift(a,bit.arshift(b,c));end"#
|
||||
r#"function()a=arshift(a,arshift(b,c));end"#
|
||||
);
|
||||
assert_eq!(luaify!(|| a && b), r#"function()return a and b;end"#);
|
||||
assert_eq!(luaify!(|| a || b), r#"function()return a or b;end"#);
|
||||
@@ -307,15 +310,15 @@ fn ops() {
|
||||
);
|
||||
assert_eq!(
|
||||
luaify!(|| -a || !--b && c >> d),
|
||||
r#"function()return-a or not-(-b)and bit.arshift(c,d);end"#
|
||||
r#"function()return-a or not-(-b)and arshift(c,d);end"#
|
||||
);
|
||||
assert_eq!(
|
||||
luaify!(|| -a || !(--b && c) >> d),
|
||||
r#"function()return-a or bit.arshift(not(-(-b)and c),d);end"#
|
||||
r#"function()return-a or arshift(not(-(-b)and c),d);end"#
|
||||
);
|
||||
assert_eq!(
|
||||
luaify!(|| a >> b << c >> d),
|
||||
r#"function()return bit.arshift(bit.lshift(bit.arshift(a,b),c),d);end"#
|
||||
r#"function()return arshift(lshift(arshift(a,b),c),d);end"#
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user