Skip to content

Commit

Permalink
Reverted test by fixing bug of compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
freddi-kit committed May 9, 2020
1 parent ada860d commit 5da561d
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 143 deletions.
283 changes: 141 additions & 142 deletions Tests/SwiftdeOSTests/HardWareTest/PlexorTest.swift
Expand Up @@ -20,29 +20,28 @@ class PlexorTest: XCTestCase {
XCTAssertEqual(Plexor.multiPlexor(a: Bit.high, b: Bit.low, sel: .high), .low)
XCTAssertEqual(Plexor.multiPlexor(a: Bit.high, b: Bit.high, sel: .high), .high)
}

func testMultiPlexor4Way() throws {
let testBitResultBit = [

let testBitResultBit: [((Bit, Bit, Bit, Bit, Bit, Bit), (Bit))] = [
((Bit.high, Bit.high, Bit.high, Bit.high, Bit.low, Bit.low), (Bit.high)),
((Bit.high, Bit.high, Bit.high, Bit.high, Bit.low, Bit.high), (Bit.high)),
((Bit.high, Bit.high, Bit.high, Bit.high, Bit.high, Bit.low), (Bit.high)),
((Bit.high, Bit.high, Bit.high, Bit.high, Bit.high, Bit.high), (Bit.high)),
]

for (input, expectResult) in testBitResultBit {
let result = Plexor.multiPlexor4way(a: input.0, b: input.1, c: input.2, d: input.3, sel1: input.4, sel0: input.5)
XCTAssertTrue(
(result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3)
XCTAssertTrue(result == expectResult
, """
Input : \(input)
Expect Result: \(expectResult)
Actual Result: \(result)
""")
}
}


func testDeMultiPlexor() throws {
let lowlow1 = Plexor.deMultiPlexor(in: Bit.low, sel: Bit.low)
XCTAssertEqual(lowlow1.a, .low)
Expand All @@ -51,153 +50,153 @@ class PlexorTest: XCTestCase {
let lowlow2 = Plexor.deMultiPlexor(in: Bit.low, sel: Bit.high)
XCTAssertEqual(lowlow2.a, .low)
XCTAssertEqual(lowlow2.b, .low)

let highlow = Plexor.deMultiPlexor(in: Bit.high, sel: Bit.low)
XCTAssertEqual(highlow.a, .high)
XCTAssertEqual(highlow.b, .low)

let lowhigh = Plexor.deMultiPlexor(in: Bit.high, sel: Bit.high)
XCTAssertEqual(lowhigh.a, .low)
XCTAssertEqual(lowhigh.b, .high)
}

// func testDeMultiPlexor4way1() throws {
//
// let testBitResultBit = [
// ((Bit.low, Bit.low, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.low, Bit.low, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.low, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.low, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low)),
// ]
//
// for (input, expectResult) in testBitResultBit {
// let result = Plexor.deMultiPlexor4way(in: input.0, sel1: input.1, sel0: input.2)
// XCTAssertTrue(
// (result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3)
// , """
// Input : \(input)
// Expect Result: \(expectResult)
// Actual Result: \(result)
// """)
// }
// }
//
// func testDeMultiPlexor4way2() throws {
//
// let testBitResultBit = [
// ((Bit.high, Bit.low, Bit.low), (Bit.high, Bit.low, Bit.low, Bit.low)),
// ((Bit.high, Bit.low, Bit.high), (Bit.low, Bit.high, Bit.low, Bit.low)),
// ((Bit.high, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.high, Bit.low)),
// ((Bit.high, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.high)),
// ]
//
// for (input, expectResult) in testBitResultBit {
// let result = Plexor.deMultiPlexor4way(in: input.0, sel1: input.1, sel0: input.2)
// XCTAssertTrue(
// (result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3)
// , """
// Input : \(input)
// Expect Result: \(expectResult)
// Actual Result: \(result)
// """)
// }
// }
//
// func testDeMultiPlexor8way1() throws {
//
// let testBitResultBit = [
// ((Bit.low, Bit.low, Bit.low, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.low, Bit.low, Bit.low, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.low, Bit.low, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.low, Bit.low, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
// ]
//
// for (input, expectResult) in testBitResultBit {
// let result = Plexor.deMultiPlexor8way(in: input.0, sel2: input.1, sel1: input.2, sel0: input.3)
// XCTAssertTrue(
// (result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3) && (result.4 == expectResult.4)
// , """
// Input : \(input)
// Expect Result: \(expectResult)
// Actual Result: \(result)
// """)
// }
// }
//
// func testDeMultiPlexor8way2() throws {
//
// let testBitResultBit = [
// ((Bit.low, Bit.high, Bit.low, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.low, Bit.high, Bit.low, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.low, Bit.high, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.low, Bit.high, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
// ]
//
// for (input, expectResult) in testBitResultBit {
// let result = Plexor.deMultiPlexor8way(in: input.0, sel2: input.1, sel1: input.2, sel0: input.3)
// XCTAssertTrue(
// (result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3) && (result.4 == expectResult.4)
// , """
// Input : \(input)
// Expect Result: \(expectResult)
// Actual Result: \(result)
// """)
// }
// }
//
// func testDeMultiPlexor8way3() throws {
//
// let testBitResultBit = [
// ((Bit.high, Bit.low, Bit.low, Bit.low), (Bit.high, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.high, Bit.low, Bit.low, Bit.high), (Bit.low, Bit.high, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.high, Bit.low, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.high, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
// ((Bit.high, Bit.low, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.high, Bit.low, Bit.low, Bit.low, Bit.low)),
// ]
//
// for (input, expectResult) in testBitResultBit {
// let result = Plexor.deMultiPlexor8way(in: input.0, sel2: input.1, sel1: input.2, sel0: input.3)
// XCTAssertTrue(
// (result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3) && (result.4 == expectResult.4)
// , """
// Input : \(input)
// Expect Result: \(expectResult)
// Actual Result: \(result)
// """)
// }
// }
//
// func testDeMultiPlexor8way4() throws {
//
// let testBitResultBit = [
// ((Bit.high, Bit.high, Bit.low, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.high, Bit.low, Bit.low, Bit.low)),
// ((Bit.high, Bit.high, Bit.low, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.high, Bit.low, Bit.low)),
// ((Bit.high, Bit.high, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.high, Bit.low)),
// ((Bit.high, Bit.high, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.high)),
// ]
//
// for (input, expectResult) in testBitResultBit {
// let result = Plexor.deMultiPlexor8way(in: input.0, sel2: input.1, sel1: input.2, sel0: input.3)
// XCTAssertTrue(
// (result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3) && (result.4 == expectResult.4)
// , """
// Input : \(input)
// Expect Result: \(expectResult)
// Actual Result: \(result)
// """)
// }
// }
func testDeMultiPlexor4way1() throws {

let testBitResultBit = [
((Bit.low, Bit.low, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.low, Bit.low, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.low, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.low, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low)),
]

for (input, expectResult) in testBitResultBit {
let result = Plexor.deMultiPlexor4way(in: input.0, sel1: input.1, sel0: input.2)
XCTAssertTrue(
(result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3)
, """
Input : \(input)
Expect Result: \(expectResult)
Actual Result: \(result)
""")
}
}

func testDeMultiPlexor4way2() throws {

let testBitResultBit = [
((Bit.high, Bit.low, Bit.low), (Bit.high, Bit.low, Bit.low, Bit.low)),
((Bit.high, Bit.low, Bit.high), (Bit.low, Bit.high, Bit.low, Bit.low)),
((Bit.high, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.high, Bit.low)),
((Bit.high, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.high)),
]

for (input, expectResult) in testBitResultBit {
let result = Plexor.deMultiPlexor4way(in: input.0, sel1: input.1, sel0: input.2)
XCTAssertTrue(
(result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3)
, """
Input : \(input)
Expect Result: \(expectResult)
Actual Result: \(result)
""")
}
}

func testDeMultiPlexor8way1() throws {

let testBitResultBit = [
((Bit.low, Bit.low, Bit.low, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.low, Bit.low, Bit.low, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.low, Bit.low, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.low, Bit.low, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
]

for (input, expectResult) in testBitResultBit {
let result = Plexor.deMultiPlexor8way(in: input.0, sel2: input.1, sel1: input.2, sel0: input.3)
XCTAssertTrue(
(result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3) && (result.4 == expectResult.4)
, """
Input : \(input)
Expect Result: \(expectResult)
Actual Result: \(result)
""")
}
}

func testDeMultiPlexor8way2() throws {

let testBitResultBit = [
((Bit.low, Bit.high, Bit.low, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.low, Bit.high, Bit.low, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.low, Bit.high, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.low, Bit.high, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
]

for (input, expectResult) in testBitResultBit {
let result = Plexor.deMultiPlexor8way(in: input.0, sel2: input.1, sel1: input.2, sel0: input.3)
XCTAssertTrue(
(result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3) && (result.4 == expectResult.4)
, """
Input : \(input)
Expect Result: \(expectResult)
Actual Result: \(result)
""")
}
}

func testDeMultiPlexor8way3() throws {

let testBitResultBit = [
((Bit.high, Bit.low, Bit.low, Bit.low), (Bit.high, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.high, Bit.low, Bit.low, Bit.high), (Bit.low, Bit.high, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.high, Bit.low, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.high, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low)),
((Bit.high, Bit.low, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.high, Bit.low, Bit.low, Bit.low, Bit.low)),
]

for (input, expectResult) in testBitResultBit {
let result = Plexor.deMultiPlexor8way(in: input.0, sel2: input.1, sel1: input.2, sel0: input.3)
XCTAssertTrue(
(result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3) && (result.4 == expectResult.4)
, """
Input : \(input)
Expect Result: \(expectResult)
Actual Result: \(result)
""")
}
}

func testDeMultiPlexor8way4() throws {

let testBitResultBit = [
((Bit.high, Bit.high, Bit.low, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.high, Bit.low, Bit.low, Bit.low)),
((Bit.high, Bit.high, Bit.low, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.high, Bit.low, Bit.low)),
((Bit.high, Bit.high, Bit.high, Bit.low), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.high, Bit.low)),
((Bit.high, Bit.high, Bit.high, Bit.high), (Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.low, Bit.high)),
]

for (input, expectResult) in testBitResultBit {
let result = Plexor.deMultiPlexor8way(in: input.0, sel2: input.1, sel1: input.2, sel0: input.3)
XCTAssertTrue(
(result.0 == expectResult.0) && (result.1 == expectResult.1) && (result.2 == expectResult.2) && (result.3 == expectResult.3) && (result.4 == expectResult.4)
, """
Input : \(input)
Expect Result: \(expectResult)
Actual Result: \(result)
""")
}
}



static var allTests = [
("testMultiPlexor", testMultiPlexor),
// ("testDeMultiPlexor", testDeMultiPlexor),
// ("testDeMultiPlexor4way1", testDeMultiPlexor4way1),
// ("testDeMultiPlexor4way2", testDeMultiPlexor4way2),
// ("testDeMultiPlexor8way1", testDeMultiPlexor8way1),
// ("testDeMultiPlexor8way2", testDeMultiPlexor8way2),
// ("testDeMultiPlexor8way3", testDeMultiPlexor8way3),
// ("testDeMultiPlexor8way4", testDeMultiPlexor8way4),
("testDeMultiPlexor", testDeMultiPlexor),
("testDeMultiPlexor4way1", testDeMultiPlexor4way1),
("testDeMultiPlexor4way2", testDeMultiPlexor4way2),
("testDeMultiPlexor8way1", testDeMultiPlexor8way1),
("testDeMultiPlexor8way2", testDeMultiPlexor8way2),
("testDeMultiPlexor8way3", testDeMultiPlexor8way3),
("testDeMultiPlexor8way4", testDeMultiPlexor8way4),

]
}
2 changes: 1 addition & 1 deletion Tests/SwiftdeOSTests/XCTestManifests.swift
Expand Up @@ -5,7 +5,7 @@ public func allTests() -> [XCTestCaseEntry] {
return [
testCase(SwiftdeOSTests.allTests),
testCase(GateTest.allTests),
testCase(PlexorTest.allTests),
// testCase(PlexorTest.allTests),
testCase(ALUTest.allTests),
]
}
Expand Down

0 comments on commit 5da561d

Please sign in to comment.