Skip to content

Commit

Permalink
Revert changes to extraSpells
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed Jan 19, 2024
1 parent bb722a4 commit 36a7041
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions tests/mbt/model/libraries/extraSpells.qnt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ module extraSpells {
assert(not(Map(2 -> 3, 4 -> 5).has(6))),
}

/// Get the map value associated with a key, or the default,
/// if the key is not present.
///
/// - @param __map the map to query
/// - @param __key the key to search for
/// - @returns the value associated with the key, if __key is
/// present in the map, and __default otherwise
pure def getOrElse(__map: a -> b, __key: a, __default: b): b = {
if (__map.has(__key)) {
__map.get(__key)
} else {
__default
}
}

run getOrElseTest = all {
assert(Map(2 -> 3, 4 -> 5).getOrElse(2, 0) == 3),
assert(Map(2 -> 3, 4 -> 5).getOrElse(7, 11) == 11),
}

/// Remove a map entry.
///
/// - @param __map a map to remove an entry from
Expand Down Expand Up @@ -167,26 +187,6 @@ module extraSpells {
assert(transform(List(1, 2, 3), __x => __x) == List(1, 2, 3)),
}

/// Get the map value associated with a key, or the default,
/// if the key is not present.
///
/// - @param __map the map to query
/// - @param __key the key to search for
/// - @returns the value associated with the key, if __key is
/// present in the map, and __default otherwise
pure def getOrElse(__map: a -> b, __key: a, __default: b): b = {
if (__map.has(__key)) {
__map.get(__key)
} else {
__default
}
}

run getOrElseTest = all {
assert(Map(2 -> 3, 4 -> 5).getOrElse(2, 0) == 3),
assert(Map(2 -> 3, 4 -> 5).getOrElse(7, 11) == 11),
}


// listForAll returns true if the given predicate function returns true for all elements in the given list,
// and false otherwise.
Expand Down

0 comments on commit 36a7041

Please sign in to comment.