From 49d005c4e12257a8a5be55429b163d8be06363fd Mon Sep 17 00:00:00 2001 From: "Md. Almas Ali" Date: Tue, 28 May 2024 16:26:13 +0600 Subject: [PATCH 1/2] fix: stdlib/array len() issue. --- stdlib/array.rn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/array.rn b/stdlib/array.rn index db0666d..f032382 100644 --- a/stdlib/array.rn +++ b/stdlib/array.rn @@ -6,7 +6,7 @@ class Array { fun map(func) { new_elements = [] - for i = 0 to this.len() { + for i = 0 to this.__len__() { arr_append(new_elements, func(arr_get(this.list, i))) } From 24fa42060acb8e3fd0b4323843b0a058c494b444 Mon Sep 17 00:00:00 2001 From: "Md. Almas Ali" Date: Tue, 28 May 2024 16:29:24 +0600 Subject: [PATCH 2/2] tests: updated test results. --- tests/len.rn.json | 2 +- tests/modules2.rn.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 tests/modules2.rn.json diff --git a/tests/len.rn.json b/tests/len.rn.json index bbca72f..aaf8684 100644 --- a/tests/len.rn.json +++ b/tests/len.rn.json @@ -1 +1 @@ -{"code": 0, "stdout": "10\n4\n3\n", "stderr": ""} \ No newline at end of file +{"code": 0, "stdout": "10\n4\n3\n2\n1\n0\nTypeError: Object of type \"Number\" has no len()\n", "stderr": ""} \ No newline at end of file diff --git a/tests/modules2.rn.json b/tests/modules2.rn.json new file mode 100644 index 0000000..08e9355 --- /dev/null +++ b/tests/modules2.rn.json @@ -0,0 +1 @@ +{"code": 0, "stdout": "A\nr\nr\na\ny\n", "stderr": ""} \ No newline at end of file