         }
     }
 
+    // MARK: - Helper Global Functions
+    public func expectEqual<T: Equatable>(
+        _ expected: T, _ actual: T,
+        _ message: @autoclosure () -> String = "",
+        file: StaticString = #file, line: UInt = #line
+        ) {
+        XCTAssertEqual(expected, actual, message, file: file, line: line)
+    }
+
+    public func expectUnreachable(
+        _ message: @autoclosure () -> String = "",
+        file: StaticString = #file, line: UInt = #line) {
+        XCTFail("this code should not be executed: \(message())", file: file, line: line)
+    }
+
+    func expectEqualPaths(
+        _ lhs: [CodingKey],
+        _ rhs: [CodingKey],
+        _ prefix: String,
+        file: StaticString = #file, line: UInt = #line) {
+        if lhs.count != rhs.count {
+            expectUnreachable("\(prefix) [CodingKey].count mismatch: \(lhs.count) != \(rhs.count)", file: file, line: line)
+            return
+        }
+
+        for (key1, key2) in zip(lhs, rhs) {
+            switch (key1.intValue, key2.intValue) {
+            case (.none, .none): break
+            case (.some(let i1), .none):
+                expectUnreachable("\(prefix) CodingKey.intValue mismatch: \(type(of: key1))(\(i1)) != nil", file: file, line: line)
+                return
+            case (.none, .some(let i2)):
+                expectUnreachable("\(prefix) CodingKey.intValue mismatch: nil != \(type(of: key2))(\(i2))", file: file, line: line)
+                return
+            case (.some(let i1), .some(let i2)):
+                guard i1 == i2 else {
+                    expectUnreachable("\(prefix) CodingKey.intValue mismatch: \(type(of: key1))(\(i1)) != \(type(of: key2))(\(i2))", file: file, line: line)
+                    return
+                }
+
+                break
+            }
+
+            expectEqual(key1.stringValue, key2.stringValue, "\(prefix) CodingKey.stringValue mismatch: \(type(of: key1))('\(key1.stringValue)') != \(type(of: key2))('\(key2.stringValue)')", file: file, line: line)
+        }
+    }
+
     // MARK: - Empty Types
-    fileprivate struct EmptyStruct: Codable, Equatable {
+    private struct EmptyStruct: Codable, Equatable {
         static func == (_ lhs: EmptyStruct, _ rhs: EmptyStruct) -> Bool {
             return true
         }
     }
 
-    fileprivate class EmptyClass: Codable, Equatable {
+    private class EmptyClass: Codable, Equatable {
         static func == (_ lhs: EmptyClass, _ rhs: EmptyClass) -> Bool {
             return true
         }

            // Person is a class with multiple fields.
            let person = Person.testValue
            _testRoundTrip(of: person, expectedYAML: "name: Johnny Appleseed\nemail: appleseed@apple.com\n")
        }

        func testEncodingTopLevelDeepStructuredType() {

        #endif
        }

        // MARK: - Encoder Features
        func testNestedContainerCodingPaths() {
            let encoder = YAMLEncoder()
            do {
                _ = try encoder.encode(NestedContainersTestType())
            } catch {
                expectUnreachable("Caught error during encoding nested container types: \(error)")
            }
        }

        func testSuperEncoderCodingPaths() {
            let encoder = YAMLEncoder()
            do {
                _ = try encoder.encode(NestedContainersTestType(testSuperEncoder: true))
            } catch {
                expectUnreachable("Caught error during encoding nested container types: \(error)")
            }
        }

        func testInterceptDecimal() {
            let expectedYAML = "value: 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n"

            // Want to make sure we write out a YAML number, not the keyed encoding here.
            // 1e127 is too big to fit natively in a Double, too, so want to make sure it's encoded as a Decimal.
            let decimal = Decimal(sign: .plus, exponent: 127, significand: Decimal(1))
            _testRoundTrip(of: TopLevelWrapper(decimal), expectedYAML: expectedYAML)

            // Optional Decimals should encode the same way.
            // FIXME: following test is blocked by https://bugs.swift.org/browse/SR-5206
//            _testRoundTrip(of: OptionalTopLevelWrapper(decimal), expectedYAML: expectedYAML)
        }

        func testInterceptURL() {
            // Want to make sure YAMLEncoder writes out single-value URLs, not the keyed encoding.
            let expectedYAML = "value: http://swift.org\n"
            let url = URL(string: "http://swift.org")!
            _testRoundTrip(of: TopLevelWrapper(url), expectedYAML: expectedYAML)

            // Optional URLs should encode the same way.
            // FIXME: following test is blocked by https://bugs.swift.org/browse/SR-5206
//            _testRoundTrip(of: OptionalTopLevelWrapper(url), expectedYAML: expectedYAML)
        }

        // MARK: - Helper Functions
        private func _testEncodeFailure<T: Encodable>(of value: T) {
            do {
                _ = try JSONEncoder().encode(value)
                expectUnreachable("Encode of top-level \(T.self) was expected to fail.")
            } catch {}
        }

        private func _testRoundTrip<T>(of value: T,
                                       expectedYAML yamlString: String? = nil,
                                       file: StaticString = #file,
