-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve capitalisation of swift types (#36)
* Fixed up String.camelCased to lowercase acronyms * Use toSwiftEnumCase when outputting enum case names * Fixup swift 5.4 errors * Add async and await to reserved words * Tidy up String extensions a little * Remove unnecessary code * Add tests This requires making the code generator use swift 5.5 * Revert to swift 5.3 to CI working
- Loading branch information
1 parent
57e256f
commit 127d008
Showing
4 changed files
with
209 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Soto for AWS open source project | ||
// | ||
// Copyright (c) 2017-2021 the Soto project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of Soto project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
@testable import SotoCodeGenerator | ||
import XCTest | ||
|
||
final class TypeNameTests: XCTestCase { | ||
func testLabels() { | ||
XCTAssertEqual("testLabel".toSwiftLabelCase(), "testLabel") | ||
XCTAssertEqual("test-label".toSwiftLabelCase(), "testLabel") | ||
XCTAssertEqual("TEST-LABEL".toSwiftLabelCase(), "testLabel") | ||
XCTAssertEqual("TEST-label".toSwiftLabelCase(), "testLabel") | ||
XCTAssertEqual("test_label".toSwiftLabelCase(), "testLabel") | ||
XCTAssertEqual("TEST_LABEL".toSwiftLabelCase(), "testLabel") | ||
XCTAssertEqual("TEST_label".toSwiftLabelCase(), "testLabel") | ||
XCTAssertEqual("TESTLabel".toSwiftLabelCase(), "testLabel") | ||
} | ||
|
||
func testVariableNames() { | ||
XCTAssertEqual("testVariable".toSwiftVariableCase(), "testVariable") | ||
XCTAssertEqual("test-variable".toSwiftVariableCase(), "testVariable") | ||
XCTAssertEqual("TEST-VARIABLE".toSwiftVariableCase(), "testVariable") | ||
XCTAssertEqual("TEST-variable".toSwiftVariableCase(), "testVariable") | ||
XCTAssertEqual("test_variable".toSwiftVariableCase(), "testVariable") | ||
XCTAssertEqual("TEST_VARIABLE".toSwiftVariableCase(), "testVariable") | ||
XCTAssertEqual("TEST_variable".toSwiftVariableCase(), "testVariable") | ||
XCTAssertEqual("TESTVariable".toSwiftVariableCase(), "testVariable") | ||
XCTAssertEqual("async".toSwiftVariableCase(), "`async`") | ||
XCTAssertEqual("for".toSwiftVariableCase(), "`for`") | ||
XCTAssertEqual("while".toSwiftVariableCase(), "`while`") | ||
XCTAssertEqual("repeat".toSwiftVariableCase(), "`repeat`") | ||
} | ||
|
||
func testClassNames() { | ||
XCTAssertEqual("testLabel".toSwiftClassCase(), "TestLabel") | ||
XCTAssertEqual("test-label".toSwiftClassCase(), "TestLabel") | ||
XCTAssertEqual("TEST-LABEL".toSwiftClassCase(), "TESTLABEL") | ||
XCTAssertEqual("TEST-label".toSwiftClassCase(), "TESTLabel") | ||
XCTAssertEqual("test_label".toSwiftClassCase(), "TestLabel") | ||
XCTAssertEqual("TEST_LABEL".toSwiftClassCase(), "TESTLABEL") | ||
XCTAssertEqual("TEST_label".toSwiftClassCase(), "TESTLabel") | ||
XCTAssertEqual("TESTLabel".toSwiftClassCase(), "TESTLabel") | ||
} | ||
} |