<commit_before>//  Copyright © 2015 <NAME>. All rights reserved.

final class TermTests: XCTestCase {
	func testLambdaTypeDescription() {
		assert(identity.value.description, ==, "λ b : Type . λ a : b . a")
		assert(try? identity.value.elaborateType(identity.type, [:], [:]).annotation.description, ==, "λ a : Type . a → a")
	}

	func testRightNestedFunctionTypesAreNotParenthesized() {
		assert((Term(.Type(0)) --> .Type).description, ==, "Type → Type")
		assert((Term(.Type(0)) --> .Type --> .Type).description, ==, "Type → Type → Type")
	}

	func testLeftNestedFunctionTypesAreParenthesized() {
		assert(((Term(.Type(0)) --> .Type) --> .Type).description, ==, "(Type → Type) → Type")
	}

	func testGlobalsPrintTheirNames() {
		assert(Term.Variable("Global").description, ==, "Global")
	}


	func testHigherOrderConstruction() {
		assert(.Type => id, ==, .Lambda(.Local(0), .Type, 0))
		assert(identity.value, ==, .Lambda(.Local(1), .Type, .Lambda(.Local(0), 1, 0)))
		assert(constant, ==, .Lambda(.Local(3), .Type, .Lambda(.Local(2), .Type, .Lambda(.Local(1), 2, .Lambda(.Local(0), 1, 0)))))
	}

	func testChurchEncodedBooleanConstruction() {
		assert(.Type => { A in (A, A) => { a, _ in a } }, ==, .Lambda(.Type, .Lambda(1, .Lambda(1, 0))))
		assert(.Type => { A in (A, A) => { _, b in b } }, ==, .Lambda( .Type, .Lambda(1, .Lambda(1, 0))))
	}

	func testFunctionTypeConstruction() {
		assert(.Type => { A in (A --> A, A) => const(A) }, ==, .Lambda(.Type, .Lambda(.Lambda(0, 0), .Lambda(0, 0))))
	}

	func testSubstitution() {
		assert(Term.Lambda(1, 0).substitute(.Local(1), with: identity.value), ==, .Lambda(identity.value, 0))
	}

	func testFreeVariablesDoNotIncludeThoseBoundByLambdas() {
		assert(Term.Lambda(.Type, 1).freeVariables, ==, [])
	}

	func testLambdasDoNotShadowFreeVariablesInTheirTypes() {<commit_msg>Correct a test of binding.<commit_after>//  Copyright © 2015 <NAME>. All rights reserved.

final class TermTests: XCTestCase {
	func testLambdaTypeDescription() {
		assert(identity.value.description, ==, "λ b : Type . λ a : b . a")
		assert(try? identity.value.elaborateType(identity.type, [:], [:]).annotation.description, ==, "λ a : Type . a → a")
	}

	func testRightNestedFunctionTypesAreNotParenthesized() {
		assert((Term(.Type(0)) --> .Type).description, ==, "Type → Type")
		assert((Term(.Type(0)) --> .Type --> .Type).description, ==, "Type → Type → Type")
	}

	func testLeftNestedFunctionTypesAreParenthesized() {
		assert(((Term(.Type(0)) --> .Type) --> .Type).description, ==, "(Type → Type) → Type")
	}

	func testGlobalsPrintTheirNames() {
		assert(Term.Variable("Global").description, ==, "Global")
	}


	func testHigherOrderConstruction() {
		assert(.Type => id, ==, .Lambda(.Local(0), .Type, 0))
		assert(identity.value, ==, .Lambda(.Local(1), .Type, .Lambda(.Local(0), 1, 0)))
		assert(constant, ==, .Lambda(.Local(3), .Type, .Lambda(.Local(2), .Type, .Lambda(.Local(1), 2, .Lambda(.Local(0), 1, 0)))))
	}

	func testChurchEncodedBooleanConstruction() {
		assert(.Type => { A in (A, A) => { a, _ in a } }, ==, .Lambda(.Type, .Lambda(1, .Lambda(1, 0))))
		assert(.Type => { A in (A, A) => { _, b in b } }, ==, .Lambda( .Type, .Lambda(1, .Lambda(1, 0))))
	}

	func testFunctionTypeConstruction() {
		assert(.Type => { A in (A --> A, A) => const(A) }, ==, .Lambda(.Type, .Lambda(.Lambda(0, 0), .Lambda(0, 0))))
	}

	func testSubstitution() {
		assert(Term.Lambda(1, 0).substitute(.Local(1), with: identity.value), ==, .Lambda(identity.value, 0))
	}

	func testFreeVariablesDoNotIncludeThoseBoundByLambdas() {
		assert(Term.Lambda(.Local(1), .Type, 1).freeVariables, ==, [])
	}

	func testLambdasDoNotShadowFreeVariablesInTheirTypes() {
{'fraction_non_alphanumeric': 0.22182906913445835, 'fraction_numerical': 0.019324986390854653, 'mean_word_length': 4.235042735042735, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '216671', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1275, 'n_words': 281}