1///|
2test "String::Clone" {
3  let 
String
x
= "hello"
4 let
String
y
=
String
x
.
(self : String) -> String
clone
()
5
(obj : &Show, content~ : String, loc~ : SourceLoc = _, args_loc~ : ArgsLoc = _) -> Unit!InspectError

Tests if the string representation of an object matches the expected content. Used primarily in test cases to verify the correctness of Show implementations and program outputs.

Parameters:

  • object : The object to be inspected. Must implement the Show trait.
  • content : The expected string representation of the object. Defaults to an empty string.
  • location : Source code location information for error reporting. Automatically provided by the compiler.
  • arguments_location : Location information for function arguments in source code. Automatically provided by the compiler.

Throws an InspectError if the actual string representation of the object does not match the expected content. The error message includes detailed information about the mismatch, including source location and both expected and actual values.

Example:

test "inspect/basic" {
  inspect(42, content="42")
  inspect("hello", content="hello")
  inspect([1, 2, 3], content="[1, 2, 3]")
}
inspect
!(
(a : String, b : String) -> Bool

Tests if two values are physically equal (i.e., point to the same memory location). Unlike structural equality testing (==), this function checks if two references point to exactly the same object in memory.

Parameters:

  • first : The first value to compare.
  • second : The second value to compare.
  • T : The type parameter representing the type of values being compared.

Returns true if both values refer to the same object in memory, false otherwise.

Example:

test "physical_equal" {
  let arr1 = [1, 2, 3]
  let arr2 = arr1
  let arr3 = [1, 2, 3]
  inspect(physical_equal(arr1, arr2), content="true") // Same object
  inspect(physical_equal(arr1, arr3), content="false") // Different objects with same content
}
physical_equal
(
String
x
,
String
y
),
String
content
="false")
6} 7