mirror of
https://github.com/zhigang1992/SwiftParsec.git
synced 2026-04-30 10:12:49 +08:00
Change enum cases to lowercase
To conform to the Swift API design guidelines change enum cases to lowercase. (see https://swift.org/documentation/api-design-guidelines/#general-conventions)
This commit is contained in:
@@ -29,19 +29,19 @@ class ExpressionTests: XCTestCase {
|
||||
postfix("²", function: { $0 * $0 })
|
||||
],
|
||||
[
|
||||
binary(">>", function: >>, assoc: .None),
|
||||
binary("<<", function: <<, assoc: .None)
|
||||
binary(">>", function: >>, assoc: .none),
|
||||
binary("<<", function: <<, assoc: .none)
|
||||
],
|
||||
[
|
||||
binary("^", function: power, assoc: .Right)
|
||||
binary("^", function: power, assoc: .right)
|
||||
],
|
||||
[
|
||||
binary("*", function: *, assoc: .Left),
|
||||
binary("/", function: /, assoc: .Left)
|
||||
binary("*", function: *, assoc: .left),
|
||||
binary("/", function: /, assoc: .left)
|
||||
],
|
||||
[
|
||||
binary("+", function: +, assoc: .Left),
|
||||
binary("-", function: -, assoc: .Left)
|
||||
binary("+", function: +, assoc: .left),
|
||||
binary("-", function: -, assoc: .left)
|
||||
]
|
||||
|
||||
]
|
||||
@@ -87,8 +87,8 @@ class ExpressionTests: XCTestCase {
|
||||
])
|
||||
|
||||
opTable.append([
|
||||
binary("*", function: *, assoc: .Left),
|
||||
binary("/", function: /, assoc: .Left)
|
||||
binary("*", function: *, assoc: .left),
|
||||
binary("/", function: /, assoc: .left)
|
||||
])
|
||||
|
||||
XCTAssertEqual(opTable.count, 2)
|
||||
@@ -102,21 +102,21 @@ class ExpressionTests: XCTestCase {
|
||||
func binary(_ name: String, function: (Int, Int) -> Int, assoc: Associativity) -> Operator<String, (), Int> {
|
||||
|
||||
let opParser = StringParser.string(name) *> GenericParser(result: function)
|
||||
return .Infix(opParser, assoc)
|
||||
return .infix(opParser, assoc)
|
||||
|
||||
}
|
||||
|
||||
func prefix(_ name: String, function: (Int) -> Int) -> Operator<String, (), Int> {
|
||||
|
||||
let opParser = StringParser.string(name) *> GenericParser(result: function)
|
||||
return .Prefix(opParser)
|
||||
return .prefix(opParser)
|
||||
|
||||
}
|
||||
|
||||
func postfix(_ name: String, function: (Int) -> Int) -> Operator<String, (), Int> {
|
||||
|
||||
let opParser = StringParser.string(name) *> GenericParser(result: function)
|
||||
return .Postfix(opParser.attempt)
|
||||
return .postfix(opParser.attempt)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -254,11 +254,11 @@ class GenericParserTests: XCTestCase {
|
||||
|
||||
switch msg {
|
||||
|
||||
case .Expected(let str) where str == labelStr:
|
||||
case .expected(let str) where str == labelStr:
|
||||
|
||||
containsExpected = true
|
||||
|
||||
case .SystemUnexpected(let str) where str == String(reflecting: input):
|
||||
case .systemUnexpected(let str) where str == String(reflecting: input):
|
||||
|
||||
containsSystemUnexpected = true
|
||||
|
||||
|
||||
@@ -450,7 +450,7 @@ class TokenTests: XCTestCase {
|
||||
|
||||
// Test for success.
|
||||
let matching = ["1", "1234", "0xf", "0xF", "0xffff", "0xFFFF", "0o1", "0o1234", "0", "-1", "-1234", "-0xf", "+0xF", "-0xffff", "+0xFFFF", "-0o1", "-0o1234", "-0", "1.0", "1234.0", "0.0", "-1.0", "-1234.0", "-0.0", "1234e5", "1.234E5", "1.234e-5", "1234E-5", "-1234e5", "-1.234E5", "-1.234e-5", "-1234e-5"]
|
||||
let expected: [Either<Int, Double>] = [.Left(1), .Left(1234), .Left(0xF), .Left(0xF), .Left(0xffff), .Left(0xFFFF), .Left(0o1), .Left(0o1234), .Left(0), .Left(-1), .Left(-1234), .Left(-0xF), .Left(0xF), .Left(-0xffff), .Left(0xFFFF), .Left(-0o1), .Left(-0o1234), .Left(-0), .Right(1.0), .Right(1234.0), .Right(0.0), .Right(-1.0), .Right(-1234.0), .Right(-0.0), .Right(1234e5), .Right(1.234E5), .Right(1.234e-5), .Right(1234E-5), .Right(-1234e5), .Right(-1.234E5), .Right(-1.234e-5), .Right(-1234e-5)]
|
||||
let expected: [Either<Int, Double>] = [.left(1), .left(1234), .left(0xF), .left(0xF), .left(0xffff), .left(0xFFFF), .left(0o1), .left(0o1234), .left(0), .left(-1), .left(-1234), .left(-0xF), .left(0xF), .left(-0xffff), .left(0xFFFF), .left(-0o1), .left(-0o1234), .left(-0), .right(1.0), .right(1234.0), .right(0.0), .right(-1.0), .right(-1234.0), .right(-0.0), .right(1234e5), .right(1.234E5), .right(1.234e-5), .right(1234E-5), .right(-1234e5), .right(-1.234E5), .right(-1.234e-5), .right(-1234e-5)]
|
||||
var index = 0
|
||||
|
||||
let errorMessage = "GenericTokenParser.number did not succeed."
|
||||
@@ -462,17 +462,17 @@ class TokenTests: XCTestCase {
|
||||
|
||||
switch result {
|
||||
|
||||
case .Left(let intRes):
|
||||
case .left(let intRes):
|
||||
|
||||
if case .Left(let val) = expect where intRes == val {
|
||||
if case .left(let val) = expect where intRes == val {
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
case .Right(let doubleRes):
|
||||
case .right(let doubleRes):
|
||||
|
||||
if case .Right(let val) = expect where doubleRes == val {
|
||||
if case .right(let val) = expect where doubleRes == val {
|
||||
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user