-- tests/aot.cat -- the C backend (ahead-of-time compilation). -- -- Built with `catscript --build tests/aot.cat /tmp/aot_native`, this must -- produce byte-for-byte the same stdout as the interpreter. It exercises -- arithmetic, calls, recursion, objects, interfaces and structural `is`. function add(a, b) return a + b end print("add:", add(2, 3)) function fact(n) if n <= 1 then return 1 end return n * fact(n - 1) end print("fact:", fact(5)) local p = { x = 1, y = 2 } p.x = p.x + 10 print("point:", p.x, p.y) interface Shape function area(self) end end class Square implements Shape function init(self, side) self.side = side end function area(self) return self.side * self.side end end local s = Square(4) print("area:", s.area(), s is Shape) print("text:", "ca" .. "tscript", 3 < 4, 5 == 5, not (2 == 3))