Files
SwiftLint/Tests/SwiftLintFrameworkTests/IdentifierNameRuleTests.swift
T
JP Simard 25a92c4e03 automatically generate LinuxMain.swift using Sourcery
This adds 6 tests that were accidentally not being run on Linux:

* LineLengthConfigurationTests.testLineLengthConfigurationInitialiserSetsIgnoresComments
* LineLengthConfigurationTests.testLineLengthConfigurationInitialiserSetsIgnoresFunctionDeclarations
* LineLengthConfigurationTests.testLineLengthConfigurationThrowsOnBadConfigValues
* LineLengthRuleTests.testLineLengthWithIgnoreCommentsEnabled
* LineLengthRuleTests.testLineLengthWithIgnoreFunctionDeclarationsEnabled
* RegionTests.testSeveralRegionsFromSeveralCommands
2017-06-02 14:28:37 -07:00

59 lines
2.5 KiB
Swift

//
// IdentifierNameRuleTests.swift
// SwiftLint
//
// Created by Javier Hernandez on 16/04/17.
// Copyright © 2017 Realm. All rights reserved.
//
import SwiftLintFramework
import XCTest
class IdentifierNameRuleTests: XCTestCase {
func testIdentifierName() {
verifyRule(IdentifierNameRule.description)
}
func testIdentifierNameWithAllowedSymbols() {
let baseDescription = IdentifierNameRule.description
let nonTriggeringExamples = baseDescription.nonTriggeringExamples + [
"let myLet$ = 0",
"let myLet% = 0",
"let myLet$% = 0"
]
let description = RuleDescription(identifier: baseDescription.identifier,
name: baseDescription.name,
description: baseDescription.description,
nonTriggeringExamples: nonTriggeringExamples,
triggeringExamples: baseDescription.triggeringExamples,
corrections: baseDescription.corrections,
deprecatedAliases: baseDescription.deprecatedAliases)
verifyRule(description, ruleConfiguration: ["allowed_symbols": ["$", "%"]])
}
func testIdentifierNameWithIgnoreStartWithLowercase() {
let baseDescription = IdentifierNameRule.description
let triggeringExamplesToRemove = [
"↓let MyLet = 0",
"enum Foo { case ↓MyEnum }"
]
let nonTriggeringExamples = baseDescription.nonTriggeringExamples +
triggeringExamplesToRemove.map { $0.replacingOccurrences(of: "↓", with: "") }
let triggeringExamples = baseDescription.triggeringExamples
.filter { !triggeringExamplesToRemove.contains($0) }
let description = RuleDescription(identifier: baseDescription.identifier,
name: baseDescription.name,
description: baseDescription.description,
nonTriggeringExamples: nonTriggeringExamples,
triggeringExamples: triggeringExamples,
corrections: baseDescription.corrections,
deprecatedAliases: baseDescription.deprecatedAliases)
verifyRule(description, ruleConfiguration: ["validates_start_lowercase": false])
}
}