From f32a45c8d8d6cf579c3eef5740b1393e35b79acf Mon Sep 17 00:00:00 2001 From: Mattia Giambirtone Date: Sat, 9 Jul 2022 13:37:16 +0200 Subject: [PATCH] Added test for scopes --- tests/calls.pbc | Bin 0 -> 299 bytes tests/closures.pbc | Bin 0 -> 231 bytes tests/dispatch.pbc | Bin 0 -> 212 bytes tests/generics.pbc | Bin 0 -> 192 bytes tests/scopes.pbc | Bin 0 -> 151 bytes tests/scopes.pn | 10 ++++++++++ tests/test.pbc | Bin 0 -> 303 bytes tests/test.pn | 19 +++++++++++++++++++ 8 files changed, 29 insertions(+) create mode 100644 tests/calls.pbc create mode 100644 tests/closures.pbc create mode 100644 tests/dispatch.pbc create mode 100644 tests/generics.pbc create mode 100644 tests/scopes.pbc create mode 100644 tests/scopes.pn create mode 100644 tests/test.pbc create mode 100644 tests/test.pn diff --git a/tests/calls.pbc b/tests/calls.pbc new file mode 100644 index 0000000000000000000000000000000000000000..7c595198c11c915ba665171c9af1cc1276d7ebba GIT binary patch literal 299 zcmXv|O>crg6dbB0BxpZQHf_>)GPVb;6bgH38YuB3n8w8P)GWB1swAjKf1v-Wvp^@A zx4ZLZ=e=c|CO_f#Dvr|67zWI(+#gh>#EZ%YE&-e4dRyuXa()kl91yj}h`}EnBu$wQXyKC4W#dY9%czUZiM_Q>=aLJ? R+fxd^TDT*J6dC)T;19-TBq9I+ literal 0 HcmV?d00001 diff --git a/tests/closures.pbc b/tests/closures.pbc new file mode 100644 index 0000000000000000000000000000000000000000..e9b004c3d5d45dafa038251942e935f766ecffa5 GIT binary patch literal 231 zcmX9&!3u&<5FCr7(x9LY9XbYeOVd<>h*Y|icIe_Mp1M&~238;0SJ`RgG#JxVBO=(C2vaX`3aZ%rYH(^R~pP!fFHfbB?$lk literal 0 HcmV?d00001 diff --git a/tests/dispatch.pbc b/tests/dispatch.pbc new file mode 100644 index 0000000000000000000000000000000000000000..0a2c193526590cc240d0640e7a5bf4b924839989 GIT binary patch literal 212 zcmWG=_4kW+iVSge_IGh*U}Rv+O)M@+Eiy7TOfokxG)goyPqnm2Hcv`UGDLL3c1M=A#hI6H)qlOT?w|M0 zViglm4JQMG0Rw{+kj2ixz{|kE%)r3N$e;_PWPvO&M_T|WD+9zjKnxTD13d-?Nht}(9?Vh$ngUb;6kq|0a4;~afed6|5KspIIyomZ literal 0 HcmV?d00001 diff --git a/tests/generics.pbc b/tests/generics.pbc new file mode 100644 index 0000000000000000000000000000000000000000..d045ca767525ebb8695a2e4c5e62bcb8d4fbb750 GIT binary patch literal 192 zcmXYoNeaS15Jg{9f;ix?$Prv?n;07$aLB@qiQpzH={D`ojl<2npO(>r|EMb7&ysY1 zTIa`PlWr3{{HwV?+|B8sIjc+PZ0t;AbreowYg`nL^|?@^Lb<6n(~)}Hmqn%~@t_SI zP$lWZ02)xKa(`aCKjmvvDG5txN~blKJC)}yfIQ#G_DyhD`D9*+W>2))zeZhj9~K!O D@O2x- literal 0 HcmV?d00001 diff --git a/tests/scopes.pbc b/tests/scopes.pbc new file mode 100644 index 0000000000000000000000000000000000000000..0d67985afd6db3935676567e55d3f545bc89078c GIT binary patch literal 151 zcmWG=_4kW+iVSge_IGh*U}Rv+O)M@+ElRaCNK7_LGf7P{PfavUvNSa@GfzrPH8nA| zOinQ}OfgEeuuQZtG+L2i_@% literal 0 HcmV?d00001 diff --git a/tests/scopes.pn b/tests/scopes.pn new file mode 100644 index 0000000..af3a92b --- /dev/null +++ b/tests/scopes.pn @@ -0,0 +1,10 @@ +var x = 5; +{ + var x = 55; + { + var x = 22; + x; + } + x; +} +x; diff --git a/tests/test.pbc b/tests/test.pbc new file mode 100644 index 0000000000000000000000000000000000000000..0265c93aaf4abdbd01d4fbcd04cd3b3ce66d547c GIT binary patch literal 303 zcmXYr%Syvw5QV?Q-Y`+Lf^XnX!N$Zkf)aC~xMA6`(&#`T%)+BA3#Fx|7*d)G4mt8dJB0EdX zY!ZF^e7DGU1rPS%0IuN>Mlk;KM{o)!nozicp|U=v>+DLychCcW#EV_uZhNBtZLp1B z5NLO}QN0l6Ddav>x>-n`?7o0(p^{Bn9FDH&dV)tPoVW4Nj XH`Q*7+qw`O;p*^HggbeY`PBRZLE$F3 literal 0 HcmV?d00001 diff --git a/tests/test.pn b/tests/test.pn new file mode 100644 index 0000000..4405153 --- /dev/null +++ b/tests/test.pn @@ -0,0 +1,19 @@ +operator `+`(a, b: int): int { + #pragma[magic: "AddInt64", pure] +} + + +fn getAdder(a, b: int): fn: int64 { + var x = a; + var y = b; + fn adder: int { + return x + y; + } + return adder; +} + + +var a = 5; +var b = 6; +var adder = getAdder(a, b); +adder();