Files

36 lines
874 B
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2024 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
import XCTest
import Future
final class BoxTests: XCTestCase {
func test_basic() {
var intOnHeap = Box<Int>(0)
XCTAssertEqual(intOnHeap[], 0)
intOnHeap[] = 123
XCTAssertEqual(intOnHeap[], 123)
XCTAssertEqual(intOnHeap.copy(), 123)
var inoutToIntOnHeap = intOnHeap.leak()
XCTAssertEqual(inoutToIntOnHeap[], 123)
inoutToIntOnHeap[] = 321
XCTAssertEqual(inoutToIntOnHeap[], 321)
}
}