From 1ed3347d44d8b1b23b46430d6c980b9738f8b968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=9C=E7=81=AF?= Date: Sat, 9 Mar 2024 22:24:11 +0800 Subject: [PATCH] test(list): add test for to_array --- list/list.mbt | 6 ++++++ list/moon.pkg.json | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/list/list.mbt b/list/list.mbt index 75d8d9c62..9a999c261 100644 --- a/list/list.mbt +++ b/list/list.mbt @@ -124,6 +124,12 @@ pub fn to_array[T : Default](self : List[T]) -> Array[T] { return arr } +test "to array" { + let list = List::[1, 2, 3, 4, 5] + let array = to_array(list) + @assertion.assert_eq(array, [1, 2, 3, 4, 5])? +} + /// Filter the list. /// /// # Example diff --git a/list/moon.pkg.json b/list/moon.pkg.json index 461766b4f..96c642ffd 100644 --- a/list/moon.pkg.json +++ b/list/moon.pkg.json @@ -1,5 +1,6 @@ { "import": [ - { "path": "moonbitlang/core/assertion", "alias": "assertion" } + { "path": "moonbitlang/core/assertion", "alias": "assertion" }, + { "path": "moonbitlang/core/array", "alias": "array" } ] } \ No newline at end of file