Skip to content

Commit

Permalink
test: add initial coverage for builtin/array_wbtest.mbt
Browse files Browse the repository at this point in the history
remove unneeded check
  • Loading branch information
bobzhang committed Dec 21, 2024
1 parent b2c86c0 commit ab18628
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 0 additions & 3 deletions builtin/array.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ pub fn clear[T](self : Array[T]) -> Unit {
/// assert_eq!(v2, [4, 5, 6])
/// ```
pub fn map[T, U](self : Array[T], f : (T) -> U) -> Array[U] {
if self.length() == 0 {
return []
}
let arr = Array::make_uninit(self.length())
for i, v in self {
arr.unsafe_set(i, f(v))
Expand Down
18 changes: 18 additions & 0 deletions builtin/array_wbtest.mbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2024 International Digital Economy Academy
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

test {
let empty : Array[Unit] = Array::make_uninit(0)
inspect!(empty, content="[]")
}

0 comments on commit ab18628

Please sign in to comment.