/* ******************************** */ /* Warning! Don't modify this file! */ /* ******************************** */ #include "PikaMain.h" #include #include PikaObj * pikaScriptInit(){ PikaObj * pikaMain = newRootObj("pikaMain", New_PikaMain); obj_run(pikaMain, "\n" "mem = PikaStdLib.MemChecker()\n" "\n" "print('mem used max:')\n" "mem.max()\n" "\n" "def EXPECT_EQ(test_name, input, expected):\n" " print('-----TEST-----')\n" " print(test_name)\n" " if input != expected:\n" " print('[Error]')\n" " print(test_name)\n" " print('[info] Expected:')\n" " print(expected)\n" " print('[info] Input:')\n" " print(input)\n" " # error\n" " while True:\n" " is_error = 1\n" " else:\n" " print('[ OK ]')\n" " print('')\n" "\n" "a = 0\n" "for i in range(0, 10):\n" " if i == 5:\n" " continue\n" " a = a + i\n" "EXPECT_EQ('for_if_continue', a, 40)\n" " \n" "a = 0\n" "for i in range(0, 10):\n" " if i == 5:\n" " break\n" " a = a + i\n" "EXPECT_EQ('for_if_break', a, 10)\n" "\n" "a = 0\n" "for i in range(0, 10):\n" " for k in range(0, 3):\n" " # print(k)\n" " a = a + k\n" "EXPECT_EQ('for_for_in_range', a, 30)\n" "\n" "a = 0\n" "for i in range(0, 10):\n" " # print(i)\n" " a = a + i\n" "EXPECT_EQ('for_in_range', a, 45)\n" "\n" "list = PikaStdData.List()\n" "list.append(7)\n" "list.append('eee')\n" "len = list.len()\n" "for item in list:\n" " # print(item)\n" " a = item\n" "EXPECT_EQ('list_for_loop', a, 'eee')\n" "\n" "\n" "list = PikaStdData.List()\n" "list.append(7)\n" "list.append('eee')\n" "len = list.len()\n" "a1 = list.get(0)\n" "a2 = list.get(1)\n" "res = iter(list)\n" "EXPECT_EQ('iter', res, list)\n" "\n" "dict = PikaStdData.Dict()\n" "dict.set('a', 1)\n" "dict.set('b', 2)\n" "dict.remove('b')\n" "a = dict.get('a')\n" "b = dict.get('b')\n" "EXPECT_EQ('PikaStdData', a, 1)\n" "EXPECT_EQ('PikaStdData_2', b, 0)\n" "\n"); return pikaMain; }