Skip to content

Conversation

@LiarPrincess
Copy link

Please read the #242 Using tests from “Violet - Python VM written in Swift” before.


Tests where we want to express things like:

  • ∀xab, (x+a)+b = x+(a+b)
  • ∀xn, (n+x)-x = n

❌ Failures

// ApplyA_ApplyB_Equals_ApplyAB.swift
func test_a_b_ab() {
  // (a/-3) / -5 = a/15
  let lhs = BigInt(.negative, magnitude: 18446744073709551615)
  let a = BigInt(-3)
  let b = BigInt(-5)
  let ab = BigInt(15)

  let r0 = (lhs / a) / b
  let r1 = lhs / ab
  XCTAssertEqual(r0, r1)
}

// ApplyA_UndoA.swift
func test_a_undoA() {
  let n = BigInt(-1)
  let x = BigInt(-9223372036854775808)
  XCTAssertEqual(n, (n + x) - x)
  XCTAssertEqual(n, (n * x) / x)
}

@LiarPrincess LiarPrincess changed the title # [BigInt tests] ❌ Property based tests [BigInt tests] ❌ Property based tests Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant