From 02bd218c1455dad03f1668180dd269953023adb7 Mon Sep 17 00:00:00 2001 From: Productive2 <48047721+Productive2@users.noreply.github.com> Date: Thu, 14 Jan 2021 20:48:37 +0000 Subject: [PATCH] Two new tests --- tests/japl/interning.jpl | 21 +++++++++++++++++++++ tests/japl/lambdachain.jpl | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/japl/interning.jpl create mode 100644 tests/japl/lambdachain.jpl diff --git a/tests/japl/interning.jpl b/tests/japl/interning.jpl new file mode 100644 index 0000000..ac9c86d --- /dev/null +++ b/tests/japl/interning.jpl @@ -0,0 +1,21 @@ +//compile time interning + +var a = "hello"; +var b = "hello"; +print(a is b);//output:true + +//runtime interning + +var f = "leafy"; +var g = "ishere"; +var h = f + g; +var j = "leafyishere"; +print(h is j);//output:true + +//different strings + +var x = "ex"; +var y = "ey"; +print(x is y);//output:false + + diff --git a/tests/japl/lambdachain.jpl b/tests/japl/lambdachain.jpl new file mode 100644 index 0000000..91e4a92 --- /dev/null +++ b/tests/japl/lambdachain.jpl @@ -0,0 +1,18 @@ + +var add2 = lambda(x) +{ + return x + 2; +}; +var sub2 = lambda(x) +{ + return x - 2; +}; +var mul2 = lambda(x) +{ + return x * 2; +}; + +print(add2(sub2(mul2(sub2(5))))); +//5-2=3 +//3*2=6 +//output:6