1///|
2test "malloc" {
3  let 
Ptr[Byte]
ptr
=
(count : UInt64) -> Ptr[Byte]
malloc
(1024)
4
(ptr : Ptr[Byte]) -> Unit
free
(
Ptr[Byte]
ptr
)
5} 6 7///| 8test "realloc" { 9 let
Ptr[Byte]
ptr
=
(count : UInt64) -> Ptr[Byte]
malloc
(1024)
10 let
Ptr[Byte]
ptr2
=
(ptr : Ptr[Byte], count : UInt64) -> Ptr[Byte]
realloc
(
Ptr[Byte]
ptr
, 2048)
11
(ptr : Ptr[Byte]) -> Unit
free
(
Ptr[Byte]
ptr2
)
12} 13 14///| 15test "Rc::from_bytes" { 16 let
Rc[Bytes]
rc
=
type Rc[T]
Rc
::
(xs : Bytes) -> Rc[Bytes]
from_bytes
(b"")
17
Rc[Bytes]
rc
.
(self : Rc[Bytes]) -> Unit
release
()
18} 19 20///| 21test "Rc::from_fixedarray" { 22 let
Rc[FixedArray[Int]]
rc
=
type Rc[T]
Rc
::
(xs : FixedArray[Int]) -> Rc[FixedArray[Int]]
from_fixedarray
([1, 2, 3])
23
Rc[FixedArray[Int]]
rc
.
(self : Rc[FixedArray[Int]]) -> Unit
release
()
24} 25 26///| 27test "Rc::bytes_scope" { 28 let
Bytes
bytes
= b"\x01\x02\x03\x04"
29 let
Int
len
=
type Rc[T]
Rc
::
(xs : Bytes, f : (ConstPtr[Byte], Int) -> Int) -> Int
scope_bytes
(
Bytes
bytes
, fn(
ConstPtr[Byte]
ptr
,
Int
len
) {
Int
len
})
30
(a : Int, b : Int, loc~ : SourceLoc = _) -> Unit raise Error

Asserts that two values are equal. If they are not equal, raises a failure with a message containing the source location and the values being compared.

Parameters:

  • a : First value to compare.
  • b : Second value to compare.
  • loc : Source location information to include in failure messages. This is usually automatically provided by the compiler.

Throws a Failure error if the values are not equal, with a message showing the location of the failing assertion and the actual values that were compared.

Example:

  assert_eq(1, 1)
  assert_eq("hello", "hello")
assert_eq
(
Int
len
,
Bytes
bytes
.
(self : Bytes) -> Int

Returns the number of bytes in a byte sequence.

Parameters:

  • bytes : The byte sequence whose length is to be determined.

Returns an integer representing the length (number of bytes) of the sequence.

Example:

  let bytes = b"\x01\x02\x03"
  inspect(bytes.length(), content="3")
  let empty = b""
  inspect(empty.length(), content="0")
length
())
31 let
Byte
b
=
type Rc[T]
Rc
::
(xs : Bytes, f : (ConstPtr[Byte], Int) -> Byte) -> Byte
scope_bytes
(
Bytes
bytes
, fn(
ConstPtr[Byte]
ptr
, _) {
ConstPtr[Byte]
ptr
.
(self : ConstPtr[Byte]) -> Byte
get
() })
32
(a : Byte, b : Byte, loc~ : SourceLoc = _) -> Unit raise Error

Asserts that two values are equal. If they are not equal, raises a failure with a message containing the source location and the values being compared.

Parameters:

  • a : First value to compare.
  • b : Second value to compare.
  • loc : Source location information to include in failure messages. This is usually automatically provided by the compiler.

Throws a Failure error if the values are not equal, with a message showing the location of the failing assertion and the actual values that were compared.

Example:

  assert_eq(1, 1)
  assert_eq("hello", "hello")
assert_eq
(
Byte
b
,
Bytes
bytes
[0])
33} 34 35///| 36test "Rc::fixedarray_scope" { 37 let
FixedArray[UInt]
arr
:
type FixedArray[A]
FixedArray
[
UInt
UInt
] = [1, 2, 3, 4, 5]
38 let
Int
len
=
type Rc[T]
Rc
::
(xs : FixedArray[UInt], f : (Ptr[UInt], Int) -> Int) -> Int
scope_fixedarray
(
FixedArray[UInt]
arr
, fn(
Ptr[UInt]
ptr
,
Int
len
) {
Int
len
})
39
(a : Int, b : Int, loc~ : SourceLoc = _) -> Unit raise Error

Asserts that two values are equal. If they are not equal, raises a failure with a message containing the source location and the values being compared.

Parameters:

  • a : First value to compare.
  • b : Second value to compare.
  • loc : Source location information to include in failure messages. This is usually automatically provided by the compiler.

Throws a Failure error if the values are not equal, with a message showing the location of the failing assertion and the actual values that were compared.

Example:

  assert_eq(1, 1)
  assert_eq("hello", "hello")
assert_eq
(
Int
len
,
FixedArray[UInt]
arr
.
(self : FixedArray[UInt]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
length
())
40 for
Int
i
in
Int
0
..<
FixedArray[UInt]
arr
.
(self : FixedArray[UInt]) -> Int

Returns the number of elements in a fixed-size array.

Parameters:

  • array : The fixed-size array whose length is to be determined.

Returns an integer representing the number of elements in the array.

Example:

  let arr = FixedArray::make(3, 42)
  inspect(arr.length(), content="3")
length
() {
41 let
UInt
b
=
type Rc[T]
Rc
::
(xs : FixedArray[UInt], f : (Ptr[UInt], Int) -> UInt) -> UInt
scope_fixedarray
(
FixedArray[UInt]
arr
, fn(
Ptr[UInt]
ptr
, _) {
Ptr[UInt]
ptr
.
(self : Ptr[UInt], offset : Int64) -> Ptr[UInt]
add
(
Int
i
.
(self : Int) -> Int64

Converts a 32-bit signed integer to a 64-bit signed integer. All 32-bit integers can be represented exactly in 64-bit integer format, so the conversion is lossless.

Parameters:

  • self : The 32-bit signed integer to be converted.

Returns a 64-bit signed integer that represents the same numerical value as the input.

Example:

  let n = 42
  inspect(n.to_int64(), content="42")
  let neg = -42
  inspect(neg.to_int64(), content="-42")
to_int64
()).
(self : Ptr[UInt]) -> UInt
get
() })
42
(a : UInt, b : UInt, loc~ : SourceLoc = _) -> Unit raise Error

Asserts that two values are equal. If they are not equal, raises a failure with a message containing the source location and the values being compared.

Parameters:

  • a : First value to compare.
  • b : Second value to compare.
  • loc : Source location information to include in failure messages. This is usually automatically provided by the compiler.

Throws a Failure error if the values are not equal, with a message showing the location of the failing assertion and the actual values that were compared.

Example:

  assert_eq(1, 1)
  assert_eq("hello", "hello")
assert_eq
(
UInt
b
,
FixedArray[UInt]
arr
(FixedArray[UInt], Int) -> UInt

Retrieves an element at the specified index from a fixed-size array. This function implements the array indexing operator [].

Parameters:

  • array : The fixed-size array to access.
  • index : The position in the array from which to retrieve the element.

Returns the element at the specified index.

Throws a runtime error if the index is out of bounds (negative or greater than or equal to the length of the array).

Example:

  let arr = FixedArray::make(3, 42)
  inspect(arr[1], content="42")
[
i])
43 } 44} 45 46///| 47test "memset" { 48 let
FixedArray[UInt64]
actual
:
type FixedArray[A]
FixedArray
[
UInt64
UInt64
] = [1, 2, 3, 4, 5]
49
type Rc[T]
Rc
::
(xs : FixedArray[UInt64], f : (Ptr[UInt64], Int) -> Unit) -> Unit
scope_fixedarray
(
FixedArray[UInt64]
actual
, fn(
Ptr[UInt64]
src
,
Int
len
) {
50 let
UInt64
len
= (
Int
len
.
(self : Int) -> Int64

Converts a 32-bit signed integer to a 64-bit signed integer. All 32-bit integers can be represented exactly in 64-bit integer format, so the conversion is lossless.

Parameters:

  • self : The 32-bit signed integer to be converted.

Returns a 64-bit signed integer that represents the same numerical value as the input.

Example:

  let n = 42
  inspect(n.to_int64(), content="42")
  let neg = -42
  inspect(neg.to_int64(), content="-42")
to_int64
()
(self : Int64, other : Int64) -> Int64

Multiplies two 64-bit integers.

Parameters:

  • self : The first 64-bit integer operand.
  • other : The second 64-bit integer operand.

Returns the product of the two 64-bit integers. If the result overflows the range of Int64, it will be truncated according to two's complement arithmetic.

Example:

  let a = 42L
  let b = 100L
  inspect(a * b, content="4200")
  let c = -42L
  inspect(c * b, content="-4200")
*
Int64
size_of_double
).
(self : Int64) -> UInt64

Reinterprets a 64-bit signed integer as an unsigned 64-bit integer without changing its bit pattern. The reinterpretation follows the standard two's complement representation rules.

Parameters:

  • self : The 64-bit signed integer to be reinterpreted.

Returns a 64-bit unsigned integer that has the same bit pattern as the input.

Example:

  let neg = -1L
  inspect(neg.reinterpret_as_uint64(), content="18446744073709551615") // All bits set to 1
  let pos = 42L
  inspect(pos.reinterpret_as_uint64(), content="42") // Positive numbers remain unchanged
reinterpret_as_uint64
()
51
(ptr : Ptr[Byte], val : Byte, count : UInt64) -> Unit
memset
(
Ptr[UInt64]
src
.
(self : Ptr[UInt64]) -> Ptr[Byte]
reinterpret_as_byte_ptr
(), 0,
UInt64
len
)
52 }) 53 let
FixedArray[UInt64]
expected
:
type FixedArray[A]
FixedArray
[
UInt64
UInt64
] = [0, 0, 0, 0, 0]
54
(a : FixedArray[UInt64], b : FixedArray[UInt64], loc~ : SourceLoc = _) -> Unit raise Error

Asserts that two values are equal. If they are not equal, raises a failure with a message containing the source location and the values being compared.

Parameters:

  • a : First value to compare.
  • b : Second value to compare.
  • loc : Source location information to include in failure messages. This is usually automatically provided by the compiler.

Throws a Failure error if the values are not equal, with a message showing the location of the failing assertion and the actual values that were compared.

Example:

  assert_eq(1, 1)
  assert_eq("hello", "hello")
assert_eq
(
FixedArray[UInt64]
actual
,
FixedArray[UInt64]
expected
)
55} 56 57///| 58test "memcpy" { 59 let
FixedArray[Int]
actual
:
type FixedArray[A]
FixedArray
[
Int
Int
] =
type FixedArray[A]
FixedArray
::
(length : Int, value : (Int) -> Int) -> FixedArray[Int]

Creates a new fixed-size array of the specified length, where each element is initialized using a function that maps indices to values.

Parameters:

  • length : The length of the array to create. If length is less than or equal to 0, returns an empty array.
  • initializer : A function that takes an index (from 0 to length - 1) and returns a value of type T for that position.

Returns a new fixed array containing the values produced by applying the initializer function to each index.

Example:

  let arr = FixedArray::makei(3, fn(i) { i * 2 })
  inspect(arr, content="[0, 2, 4]")
makei
(10, fn(
Int
i
) {
Int
i
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
+
1 })
60 let
FixedArray[Int]
expected
:
type FixedArray[A]
FixedArray
[
Int
Int
] = [1, 2, 3, 4, 1, 2, 3, 4, 9, 10]
61
type Rc[T]
Rc
::
(xs : FixedArray[Int], f : (Ptr[Int], Int) -> Unit) -> Unit
scope_fixedarray
(
FixedArray[Int]
actual
, fn(
Ptr[Int]
src
,
Int
len
) {
62 let
Ptr[Int]
dest
=
Ptr[Int]
src
.
(self : Ptr[Int], offset : Int64) -> Ptr[Int]
add
(4)
63 let
UInt64
len
= (4L
(self : Int64, other : Int64) -> Int64

Multiplies two 64-bit integers.

Parameters:

  • self : The first 64-bit integer operand.
  • other : The second 64-bit integer operand.

Returns the product of the two 64-bit integers. If the result overflows the range of Int64, it will be truncated according to two's complement arithmetic.

Example:

  let a = 42L
  let b = 100L
  inspect(a * b, content="4200")
  let c = -42L
  inspect(c * b, content="-4200")
*
Int64
size_of_int
).
(self : Int64) -> UInt64

Reinterprets a 64-bit signed integer as an unsigned 64-bit integer without changing its bit pattern. The reinterpretation follows the standard two's complement representation rules.

Parameters:

  • self : The 64-bit signed integer to be reinterpreted.

Returns a 64-bit unsigned integer that has the same bit pattern as the input.

Example:

  let neg = -1L
  inspect(neg.reinterpret_as_uint64(), content="18446744073709551615") // All bits set to 1
  let pos = 42L
  inspect(pos.reinterpret_as_uint64(), content="42") // Positive numbers remain unchanged
reinterpret_as_uint64
()
64
(dest : Ptr[Byte], src : ConstPtr[Byte], count : UInt64) -> Unit
memcpy
(
65
Ptr[Int]
dest
.
(self : Ptr[Int]) -> Ptr[Byte]
reinterpret_as_byte_ptr
(),
66
Ptr[Int]
src
.
(self : Ptr[Int]) -> ConstPtr[Byte]
reinterpret_as_const_byte_ptr
(),
67
UInt64
len
,
68 ) 69 }) 70
(a : FixedArray[Int], b : FixedArray[Int], loc~ : SourceLoc = _) -> Unit raise Error

Asserts that two values are equal. If they are not equal, raises a failure with a message containing the source location and the values being compared.

Parameters:

  • a : First value to compare.
  • b : Second value to compare.
  • loc : Source location information to include in failure messages. This is usually automatically provided by the compiler.

Throws a Failure error if the values are not equal, with a message showing the location of the failing assertion and the actual values that were compared.

Example:

  assert_eq(1, 1)
  assert_eq("hello", "hello")
assert_eq
(
FixedArray[Int]
expected
,
FixedArray[Int]
actual
)
71} 72 73///| 74test "memmove" { 75 let
FixedArray[Int]
actual
:
type FixedArray[A]
FixedArray
[
Int
Int
] =
type FixedArray[A]
FixedArray
::
(length : Int, value : (Int) -> Int) -> FixedArray[Int]

Creates a new fixed-size array of the specified length, where each element is initialized using a function that maps indices to values.

Parameters:

  • length : The length of the array to create. If length is less than or equal to 0, returns an empty array.
  • initializer : A function that takes an index (from 0 to length - 1) and returns a value of type T for that position.

Returns a new fixed array containing the values produced by applying the initializer function to each index.

Example:

  let arr = FixedArray::makei(3, fn(i) { i * 2 })
  inspect(arr, content="[0, 2, 4]")
makei
(10, fn(
Int
i
) {
Int
i
(self : Int, other : Int) -> Int

Adds two 32-bit signed integers. Performs two's complement arithmetic, which means the operation will wrap around if the result exceeds the range of a 32-bit integer.

Parameters:

  • self : The first integer operand.
  • other : The second integer operand.

Returns a new integer that is the sum of the two operands. If the mathematical sum exceeds the range of a 32-bit integer (-2,147,483,648 to 2,147,483,647), the result wraps around according to two's complement rules.

Example:

  inspect(42 + 1, content="43")
  inspect(2147483647 + 1, content="-2147483648") // Overflow wraps around to minimum value
+
1 })
76 let
FixedArray[Int]
expected
:
type FixedArray[A]
FixedArray
[
Int
Int
] = [1, 2, 3, 4, 1, 2, 3, 4, 9, 10]
77
type Rc[T]
Rc
::
(xs : FixedArray[Int], f : (Ptr[Int], Int) -> Unit) -> Unit
scope_fixedarray
(
FixedArray[Int]
actual
, fn(
Ptr[Int]
src
,
Int
len
) {
78 let
Ptr[Int]
dest
=
Ptr[Int]
src
.
(self : Ptr[Int], offset : Int64) -> Ptr[Int]
add
(4)
79 let
UInt64
len
= (4L
(self : Int64, other : Int64) -> Int64

Multiplies two 64-bit integers.

Parameters:

  • self : The first 64-bit integer operand.
  • other : The second 64-bit integer operand.

Returns the product of the two 64-bit integers. If the result overflows the range of Int64, it will be truncated according to two's complement arithmetic.

Example:

  let a = 42L
  let b = 100L
  inspect(a * b, content="4200")
  let c = -42L
  inspect(c * b, content="-4200")
*
Int64
size_of_int
).
(self : Int64) -> UInt64

Reinterprets a 64-bit signed integer as an unsigned 64-bit integer without changing its bit pattern. The reinterpretation follows the standard two's complement representation rules.

Parameters:

  • self : The 64-bit signed integer to be reinterpreted.

Returns a 64-bit unsigned integer that has the same bit pattern as the input.

Example:

  let neg = -1L
  inspect(neg.reinterpret_as_uint64(), content="18446744073709551615") // All bits set to 1
  let pos = 42L
  inspect(pos.reinterpret_as_uint64(), content="42") // Positive numbers remain unchanged
reinterpret_as_uint64
()
80
(dest : Ptr[Byte], src : ConstPtr[Byte], count : UInt64) -> Unit
memmove
(
81
Ptr[Int]
dest
.
(self : Ptr[Int]) -> Ptr[Byte]
reinterpret_as_byte_ptr
(),
82
Ptr[Int]
src
.
(self : Ptr[Int]) -> ConstPtr[Byte]
reinterpret_as_const_byte_ptr
(),
83
UInt64
len
,
84 ) 85 }) 86
(a : FixedArray[Int], b : FixedArray[Int], loc~ : SourceLoc = _) -> Unit raise Error

Asserts that two values are equal. If they are not equal, raises a failure with a message containing the source location and the values being compared.

Parameters:

  • a : First value to compare.
  • b : Second value to compare.
  • loc : Source location information to include in failure messages. This is usually automatically provided by the compiler.

Throws a Failure error if the values are not equal, with a message showing the location of the failing assertion and the actual values that were compared.

Example:

  assert_eq(1, 1)
  assert_eq("hello", "hello")
assert_eq
(
FixedArray[Int]
expected
,
FixedArray[Int]
actual
)
87} 88 89///| 90test "ConstCString::to_bytes" { 91 let
Bytes
expected
= b"hello world\x00"
92 let
Bytes
actual
=
type Rc[T]
Rc
::
(xs : Bytes, f : (ConstPtr[Byte], Int) -> Bytes) -> Bytes
scope_bytes
(
Bytes
expected
, fn(
ConstPtr[Byte]
ptr
, _) {
93 let
CStr
cstr
=
type CStr ConstPtr[Byte]
CStr
::
(ptr : ConstPtr[Byte]) -> CStr
unsafe_from_const_byte_ptr
(
ConstPtr[Byte]
ptr
)
94
CStr
cstr
.
(self : CStr) -> Bytes
to_bytes
()
95 }) 96
(a : Bytes, b : Bytes, loc~ : SourceLoc = _) -> Unit raise Error

Asserts that two values are equal. If they are not equal, raises a failure with a message containing the source location and the values being compared.

Parameters:

  • a : First value to compare.
  • b : Second value to compare.
  • loc : Source location information to include in failure messages. This is usually automatically provided by the compiler.

Throws a Failure error if the values are not equal, with a message showing the location of the failing assertion and the actual values that were compared.

Example:

  assert_eq(1, 1)
  assert_eq("hello", "hello")
assert_eq
(
Bytes
actual
,
Bytes
expected
)
97} 98 99///| 100test "CString::to_bytes" { 101 let
Bytes
expected
= b"hello world\x00"
102 let
Bytes
actual
=
type Rc[T]
Rc
::
(xs : Bytes, f : (ConstPtr[Byte], Int) -> Bytes) -> Bytes
scope_bytes
(
Bytes
expected
, fn(
ConstPtr[Byte]
ptr
, _) {
103 let
CStr
cstr
=
type CStr ConstPtr[Byte]
CStr
::
(ptr : ConstPtr[Byte]) -> CStr
unsafe_from_const_byte_ptr
(
ConstPtr[Byte]
ptr
)
104
CStr
cstr
.
(self : CStr) -> Bytes
to_bytes
()
105 }) 106
(a : Bytes, b : Bytes, loc~ : SourceLoc = _) -> Unit raise Error

Asserts that two values are equal. If they are not equal, raises a failure with a message containing the source location and the values being compared.

Parameters:

  • a : First value to compare.
  • b : Second value to compare.
  • loc : Source location information to include in failure messages. This is usually automatically provided by the compiler.

Throws a Failure error if the values are not equal, with a message showing the location of the failing assertion and the actual values that were compared.

Example:

  assert_eq(1, 1)
  assert_eq("hello", "hello")
assert_eq
(
Bytes
actual
,
Bytes
expected
)
107} 108 109///| 110test "memcpy" { 111 let
FixedArray[Double]
lhs
:
type FixedArray[A]
FixedArray
[
Double
Double
] = [1.0, 2.0, 3.0, 4.0]
112 let
FixedArray[Double]
rhs
:
type FixedArray[A]
FixedArray
[
Double
Double
] = [1.0, 2.0, 3.0, 4.0, 5]
113 let
Rc[FixedArray[Double]]
rc_lhs
=
type Rc[T]
Rc
::
(xs : FixedArray[Double]) -> Rc[FixedArray[Double]]
from_fixedarray
(
FixedArray[Double]
lhs
)
114 let
Rc[FixedArray[Double]]
rc_rhs
=
type Rc[T]
Rc
::
(xs : FixedArray[Double]) -> Rc[FixedArray[Double]]
from_fixedarray
(
FixedArray[Double]
rhs
)
115 let
Ptr[Double]
lhs_ptr
=
type Ptr[T]
Ptr
::
(rc : Rc[FixedArray[Double]]) -> Ptr[Double]
from_rc_fixedarray
(
Rc[FixedArray[Double]]
rc_lhs
)
116 let
Ptr[Double]
rhs_ptr
=
type Ptr[T]
Ptr
::
(rc : Rc[FixedArray[Double]]) -> Ptr[Double]
from_rc_fixedarray
(
Rc[FixedArray[Double]]
rc_rhs
)
117 let
Int
cmp
=
(a : ConstPtr[Byte], b : ConstPtr[Byte], count : UInt64) -> Int
memcmp
(
118
Ptr[Double]
lhs_ptr
.
(self : Ptr[Double]) -> ConstPtr[Byte]
reinterpret_as_const_byte_ptr
(),
119
Ptr[Double]
rhs_ptr
.
(self : Ptr[Double]) -> ConstPtr[Byte]
reinterpret_as_const_byte_ptr
(),
120 (4L
(self : Int64, other : Int64) -> Int64

Multiplies two 64-bit integers.

Parameters:

  • self : The first 64-bit integer operand.
  • other : The second 64-bit integer operand.

Returns the product of the two 64-bit integers. If the result overflows the range of Int64, it will be truncated according to two's complement arithmetic.

Example:

  let a = 42L
  let b = 100L
  inspect(a * b, content="4200")
  let c = -42L
  inspect(c * b, content="-4200")
*
Int64
size_of_double
).
(self : Int64) -> UInt64

Reinterprets a 64-bit signed integer as an unsigned 64-bit integer without changing its bit pattern. The reinterpretation follows the standard two's complement representation rules.

Parameters:

  • self : The 64-bit signed integer to be reinterpreted.

Returns a 64-bit unsigned integer that has the same bit pattern as the input.

Example:

  let neg = -1L
  inspect(neg.reinterpret_as_uint64(), content="18446744073709551615") // All bits set to 1
  let pos = 42L
  inspect(pos.reinterpret_as_uint64(), content="42") // Positive numbers remain unchanged
reinterpret_as_uint64
(),
121 ) 122
(f : () -> Unit raise Error, finally_~ : () -> Unit) -> Unit raise Error
try_finally
(fn() {
(a : Int, b : Int, loc~ : SourceLoc = _) -> Unit raise Error

Asserts that two values are equal. If they are not equal, raises a failure with a message containing the source location and the values being compared.

Parameters:

  • a : First value to compare.
  • b : Second value to compare.
  • loc : Source location information to include in failure messages. This is usually automatically provided by the compiler.

Throws a Failure error if the values are not equal, with a message showing the location of the failing assertion and the actual values that were compared.

Example:

  assert_eq(1, 1)
  assert_eq("hello", "hello")
assert_eq
(
Int
cmp
, 0) },
() -> Unit
finally_
=fn() {
123
Rc[FixedArray[Double]]
rc_lhs
.
(self : Rc[FixedArray[Double]]) -> Unit
release
()
124
Rc[FixedArray[Double]]
rc_rhs
.
(self : Rc[FixedArray[Double]]) -> Unit
release
()
125 }) 126} 127 128///| 129test "is_null" { 130 let
Ptr[Int16]
ptr
:
type Ptr[T]
Ptr
[
Int16
Int16
] =
ConstPtr[Unit]
null_pointer
|>
(x : ConstPtr[Unit]) -> Ptr[Int16]
unsafe_coerce
131
(a : Bool, b : Bool, loc~ : SourceLoc = _) -> Unit raise Error

Asserts that two values are equal. If they are not equal, raises a failure with a message containing the source location and the values being compared.

Parameters:

  • a : First value to compare.
  • b : Second value to compare.
  • loc : Source location information to include in failure messages. This is usually automatically provided by the compiler.

Throws a Failure error if the values are not equal, with a message showing the location of the failing assertion and the actual values that were compared.

Example:

  assert_eq(1, 1)
  assert_eq("hello", "hello")
assert_eq
(
Ptr[Int16]
ptr
.
(self : Ptr[Int16]) -> Bool
is_null
(), true)
132} 133