Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Add function to apply accessibility identifiers | /*
| _ ____ ____ _
| | |βΎ| β |-| β |βΎ| |
| | | βΎβΎβΎβΎ| |βΎβΎβΎβΎ | |
| βΎ βΎ βΎ
*/
import Foundation
public protocol Nameable { }
public extension Nameable {
public static var name: String {
return String(describing: Self.self)
}
}
| /*
| _ ____ ____ _
| | |βΎ| β |-| β |βΎ| |
| | | βΎβΎβΎβΎ| |βΎβΎβΎβΎ | |
| βΎ βΎ βΎ
*/
import Foundation
public protocol Nameable { }
public extension Nameable {
public static var name: String {
return String(describing: Self.self)
}
public func addAccessibilityIdentif... |
Add a check for the implicit import line to this testcase. | // RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: %target-build-swift -module-cache-path %t/clang-module-cache -emit-ir -g %s -o - | FileCheck %s
// CHECK: i32 {{.*}}, metadata !{{[0-9]+}}, metadata ![[ObjectiveC:[0-9]+]], {{.*}}metadata !"_TtCSo8Protocol"} ; [ DW_TAG_structure_type ] [Protocol]
// CHECK: ![[ObjectiveC]] ... | // RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: %target-build-swift -module-cache-path %t/clang-module-cache -emit-ir -g %s -o - | FileCheck %s
// CHECK: i32 {{.*}}, metadata !{{[0-9]+}}, metadata ![[ObjectiveC:[0-9]+]], {{.*}}metadata !"_TtCSo8Protocol"} ; [ DW_TAG_structure_type ] [Protocol]
// CHECK: ![[ObjectiveC]] ... |
Simplify output of clock face emojis | //
// Time.swift
// EmojiTimeFormatter
//
// Created by Thomas Paul Mann on 21/08/16.
// Copyright Β© 2016 Thomas Paul Mann. All rights reserved.
//
public enum ClockFaceEmoji: String {
// Whole
case one = "π"
case two = "π"
case three = "π"
case four = "π"
case five = "π"
case si... | //
// Time.swift
// EmojiTimeFormatter
//
// Created by Thomas Paul Mann on 21/08/16.
// Copyright Β© 2016 Thomas Paul Mann. All rights reserved.
//
public enum ClockFaceEmoji: String {
// Whole
case one = "π"
case two = "π"
case three = "π"
case four = "π"
case five = "π"
case si... |
Add missing arg in ContactLog initializer in test | //
// ContactLogsTests.swift
// FiveCalls
//
// Created by Ben Scheirman on 2/5/17.
// Copyright Β© 2017 5calls. All rights reserved.
//
import XCTest
import Pantry
@testable import FiveCalls
class ContactLogsTests: XCTestCase {
override func setUp() {
super.setUp()
Pantry.removeAllCache()... | //
// ContactLogsTests.swift
// FiveCalls
//
// Created by Ben Scheirman on 2/5/17.
// Copyright Β© 2017 5calls. All rights reserved.
//
import XCTest
import Pantry
@testable import FiveCalls
class ContactLogsTests: XCTestCase {
override func setUp() {
super.setUp()
Pantry.removeAllCache()... |
Update iOS example to use connection state change delegate | //
// ViewController.swift
// iOS Example
//
// Created by Hamilton Chapman on 24/02/2015.
// Copyright (c) 2015 Pusher. All rights reserved.
//
import UIKit
import PusherSwift
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setu... | //
// ViewController.swift
// iOS Example
//
// Created by Hamilton Chapman on 24/02/2015.
// Copyright (c) 2015 Pusher. All rights reserved.
//
import UIKit
import PusherSwift
class ViewController: UIViewController, ConnectionStateChangeDelegate {
override func viewDidLoad() {
super.viewDidLoad()
... |
Define gradient stop colours for various temperature tiers | // Copyright Β© 2016 Gavan Chan. All rights reserved.
import UIKit
final class PlaceholderWeatherViewController: UIViewController {
@IBOutlet private weak var locationLabel: UILabel!
@IBOutlet private weak var weatherInformationLabel: UILabel!
}
final class PlaceholderWeatherView: UIView {
override static va... | // Copyright Β© 2016 Gavan Chan. All rights reserved.
import UIKit
final class PlaceholderWeatherViewController: UIViewController {
@IBOutlet private weak var locationLabel: UILabel!
@IBOutlet private weak var weatherInformationLabel: UILabel!
}
final class PlaceholderWeatherView: UIView {
enum Theme {
... |
Update for Xcode 8 beta 4 | //
// _RecursiveLock.swift
// SwiftTask
//
// Created by Yasuhiro Inami on 2015/05/18.
// Copyright (c) 2015εΉ΄ Yasuhiro Inami. All rights reserved.
//
import Darwin
internal final class _RecursiveLock
{
private let mutex: UnsafeMutablePointer<pthread_mutex_t>
private let attribute: UnsafeMutablePointer<pth... | //
// _RecursiveLock.swift
// SwiftTask
//
// Created by Yasuhiro Inami on 2015/05/18.
// Copyright (c) 2015εΉ΄ Yasuhiro Inami. All rights reserved.
//
import Darwin
internal final class _RecursiveLock
{
private let mutex: UnsafeMutablePointer<pthread_mutex_t>
private let attribute: UnsafeMutablePointer<pth... |
Split lines by a pipe symbol | //
// main.swift
// ParseCSV
//
// Created by Alexander Farber on 27.06.21.
//
import Foundation
func process(string: String) throws {
print("your code here")
}
func processFile(at url: URL) throws {
let s = try String(contentsOf: url)
try process(string: s)
}
func main() {
guard CommandLine.argu... | //
// main.swift
// ParseCSV
//
// Created by Alexander Farber on 27.06.21.
//
import Foundation
func process(string: String) throws {
let lines = string.split(separator: "\n")
for line in lines {
let columns = line.split(separator: "|", omittingEmptySubsequences: true)
for column in column... |
Add importing Glibc for Linux platforms | /*
The MIT License (MIT)
Copyright (c) 2015 Shun Takebayashi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modif... | /*
The MIT License (MIT)
Copyright (c) 2015 Shun Takebayashi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modif... |
Add CEvent and ConfigFile imports | import PackageDescription
let package = Package(
name: "Smud"
)
| import PackageDescription
let package = Package(
name: "Smud",
dependencies: [
.Package(url: "https://github.com/smud/CEvent.git", majorVersion: 0),
.Package(url: "https://github.com/smud/ConfigFile.git", majorVersion: 0),
]
)
|
Update the iOSSwiftTest to work with Swift 2.0 | //
// Formatter.swift
// Lumberjack
//
// Created by C.W. Betts on 10/3/14.
//
//
import Foundation
import CocoaLumberjack.DDDispatchQueueLogFormatter
class Formatter: DDDispatchQueueLogFormatter, DDLogFormatter {
let threadUnsafeDateFormatter: NSDateFormatter
override init() {
threadUnsafeDat... | //
// Formatter.swift
// Lumberjack
//
// Created by C.W. Betts on 10/3/14.
//
//
import Foundation
import CocoaLumberjack.DDDispatchQueueLogFormatter
class Formatter: DDDispatchQueueLogFormatter {
let threadUnsafeDateFormatter: NSDateFormatter
override init() {
threadUnsafeDateFormatter = NSD... |
Update generated test index names | //
// OnlineTestCase.swift
//
//
// Created by Vladislav Fitc on 05/03/2020.
//
import Foundation
import XCTest
@testable import AlgoliaSearchClientSwift
class OnlineTestCase: XCTestCase {
var client: Client!
var index: Index!
let expectationTimeout: TimeInterval = 100
/// Abstract base class for online... | //
// OnlineTestCase.swift
//
//
// Created by Vladislav Fitc on 05/03/2020.
//
import Foundation
import XCTest
@testable import AlgoliaSearchClientSwift
class OnlineTestCase: XCTestCase {
var client: Client!
var index: Index!
let expectationTimeout: TimeInterval = 100
/// Abstract base class for online... |
Add a tableView with constraints to the AllChatsVC | //
// AllChatsViewController.swift
// V
//
// Created by Dulio Denis on 5/17/16.
// Copyright Β© 2016 Dulio Denis. All rights reserved.
//
import UIKit
import CoreData
class AllChatsViewController: UIViewController {
var context: NSManagedObjectContext?
private var fetchedResultsController: NSFetchedResul... | //
// AllChatsViewController.swift
// V
//
// Created by Dulio Denis on 5/17/16.
// Copyright Β© 2016 Dulio Denis. All rights reserved.
//
import UIKit
import CoreData
class AllChatsViewController: UIViewController {
var context: NSManagedObjectContext?
private var fetchedResultsController: NSFetchedResul... |
Add missing test for divider | import XCTest
import SwiftUI
@testable import ViewInspector
final class DividerTests: XCTestCase {
func testExtractionFromSingleViewContainer() throws {
let view = AnyView(Divider())
XCTAssertNoThrow(try view.inspect().divider())
}
func testExtractionFromMultipleViewContainer() th... | import XCTest
import SwiftUI
@testable import ViewInspector
final class DividerTests: XCTestCase {
func testInspect() throws {
XCTAssertNoThrow(try Divider().inspect())
}
func testExtractionFromSingleViewContainer() throws {
let view = AnyView(Divider())
XCTAssertNoThrow(t... |
Add another tests for HalfToneDyadSpeller | //
// HalfToneDyadSpellerTests.swift
// PitchSpellingTools
//
// Created by James Bean on 5/12/16.
//
//
import XCTest
import Pitch
@testable import PitchSpellingTools
class HalfToneDyadSpellerTests: XCTestCase {
func testCG() {
let dyad = Dyad(Pitch(noteNumber: 60.0), Pitch(noteNumber: 67.0))
... | //
// HalfToneDyadSpellerTests.swift
// PitchSpellingTools
//
// Created by James Bean on 5/12/16.
//
//
import XCTest
import Pitch
@testable import PitchSpellingTools
class HalfToneDyadSpellerTests: XCTestCase {
func testCG() {
let dyad = Dyad(Pitch(noteNumber: 60.0), Pitch(noteNumber: 67.0))
... |
Fix test by providing more invalid params | import Quick
import Nimble
@testable import Elephant
class DatabaseSpec: QuickSpec {
override func spec() {
describe("connect") {
context("with valid connection parameters") {
it("returns a connection") {
expect {
try Database.conn... | import Quick
import Nimble
@testable import Elephant
class DatabaseSpec: QuickSpec {
override func spec() {
describe("connect") {
context("with valid connection parameters") {
it("returns a connection") {
expect {
try Database.conn... |
Use shared instead of sharedInstance | import Cocoa
class PreferencesWindowController: NSWindowController {
static let sharedInstance: PreferencesWindowController = PreferencesWindowController(windowNibName: "Preferences")
}
| import Cocoa
class PreferencesWindowController: NSWindowController {
static let shared = PreferencesWindowController(windowNibName: "Preferences")
}
|
Add documentation about the motivation of the FileString typealias. | import Foundation
#if _runtime(_ObjC)
public typealias FileString = String
#else
public typealias FileString = StaticString
#endif
public final class SourceLocation : NSObject {
public let file: FileString
public let line: UInt
override init() {
file = "Unknown File"
line = 0
}
i... | import Foundation
// Ideally we would always use `StaticString` as the type for tracking the file name
// that expectations originate from, for consistency with `assert` etc. from the
// stdlib, and because recent versions of the XCTest overlay require `StaticString`
// when calling `XCTFail`. Under the Objective-C ru... |
Update test to match llvm.dbg.value change | // RUN: %target-swift-frontend %s -g -emit-ir -o - | %FileCheck %s
// REQUIRES: objc_interop, CPU=x86_64
import simd
func use<T>(_ x: T) {}
func getInt32() -> Int32 { return -1 }
public func rangeExtension(x: Int32, y: Int32) {
let p = int2(x, y)
// CHECK: define {{.*}}rangeExtension
// CHECK: llvm.dbg.value(m... | // RUN: %target-swift-frontend %s -g -emit-ir -o - | %FileCheck %s
// REQUIRES: objc_interop, CPU=x86_64
import simd
func use<T>(_ x: T) {}
func getInt32() -> Int32 { return -1 }
public func rangeExtension(x: Int32, y: Int32) {
let p = int2(x, y)
// CHECK: define {{.*}}rangeExtension
// CHECK: llvm.dbg.value(m... |
Set JSON as default content type | import Foundation
import When
public class Networking {
enum SessionTaskKind {
case Data, Upload, Download
}
let sessionConfiguration: SessionConfiguration
lazy var session: NSURLSession = {
return NSURLSession(configuration: self.sessionConfiguration.value)
}()
public init(sessionConfiguration... | import Foundation
import When
public class Networking {
enum SessionTaskKind {
case Data, Upload, Download
}
let sessionConfiguration: SessionConfiguration
lazy var session: NSURLSession = {
return NSURLSession(configuration: self.sessionConfiguration.value)
}()
public init(sessionConfiguration... |
Test that empty trees are empty. | // Copyright (c) 2015 Rob Rix. All rights reserved.
final class BinaryTreeTests: XCTestCase {
func testEmptyTreesAreNotLeaves() {
XCTAssertFalse(BinaryTree<Int>().isLeaf)
}
func testLeavesAreLeaves() {
XCTAssert(BinaryTree(0).isLeaf)
}
func testLeavesAreNonEmpty() {
XCTAssertFalse(BinaryTree(0).isEmpty)
... | // Copyright (c) 2015 Rob Rix. All rights reserved.
final class BinaryTreeTests: XCTestCase {
func testEmptyTreesAreEmpty() {
XCTAssert(BinaryTree<Int>().isEmpty)
}
func testEmptyTreesAreNotLeaves() {
XCTAssertFalse(BinaryTree<Int>().isLeaf)
}
func testLeavesAreLeaves() {
XCTAssert(BinaryTree(0).isLeaf)
... |
Add bolusVolume to NS enacted struct | //
// LoopEnacted.swift
// RileyLink
//
// Created by Pete Schwamb on 7/28/16.
// Copyright Β© 2016 Pete Schwamb. All rights reserved.
//
import Foundation
public struct LoopEnacted {
typealias RawValue = [String: Any]
let rate: Double
let duration: TimeInterval
let timestamp: Date
let receive... | //
// LoopEnacted.swift
// RileyLink
//
// Created by Pete Schwamb on 7/28/16.
// Copyright Β© 2016 Pete Schwamb. All rights reserved.
//
import Foundation
public struct LoopEnacted {
typealias RawValue = [String: Any]
let rate: Double
let duration: TimeInterval
let timestamp: Date
let receive... |
Update package manifest to Swift 4 format. | import Foundation
import PackageDescription
let package = Package(
name: "iCalendar",
dependencies: [
.Package(url: "https://github.com/antitypical/Result.git", versions: Version(3, 2, 3)..<Version(3, .max, .max)),
.Package(url: "https://github.com/Quick/Quick.git", majorVersion: 1, minor: 1),
... | // swift-tools-version:4.0
import PackageDescription
let package = Package(
name: "iCalendar",
products: [
.library(
name: "iCalendar",
targets: ["iCalendar"]),
],
dependencies: [
.package(url: "https://github.com/antitypical/Result.git", from: "3.0.0"),
... |
Optimize code style for Decode Ways | /**
* Question Link: https://leetcode.com/problems/decode-ways/
* Primary idea: Dynamic Programming, dp[i] = dp[i - 1] + dp[i - 2],
* determine if current one or two characters are number at first
* Time Complexity: O(n), Space Complexity: O(n)
*
*/
class DecodeWays {
func numDecodings(_ s: St... | /**
* Question Link: https://leetcode.com/problems/decode-ways/
* Primary idea: Dynamic Programming, dp[i] = dp[i - 1] + dp[i - 2],
* determine if current one or two characters are number at first
* Time Complexity: O(n), Space Complexity: O(n)
*
*/
class DecodeWays {
func numDecodings(_ s: St... |
Make the test case from r31995 exercise the failure path too. | // RUN: rm -rf %t && mkdir %t
// RUN: %target-swift-frontend -emit-module -o %t %s -module-name Import
// RUN: %target-swift-frontend -parse -I %t %s -module-name main -DMAIN
// Note: This file is compiled both as a library and as a client of that library.
import Import
public func test() {
Import.test()
}
| // RUN: rm -rf %t && mkdir %t
// RUN: %target-swift-frontend -emit-module -o %t %s -module-name Import
// RUN: %target-swift-frontend -parse -I %t %s -module-name main -DMAIN -verify
// Note: This file is compiled both as a library and as a client of that library. The -verify checks only apply to the client.
import I... |
Add a constructor for a fresh identifier in a graph. | // Copyright (c) 2014 Rob Rix. All rights reserved.
public struct Identifier: Comparable, Hashable, Printable {
public init() {
self.value = Identifier.cursor++
}
// MARK: Endpoint constructors
public func input(index: Int) -> Edge.Destination {
return (identifier: self, inputIndex: index)
}
public func... | // Copyright (c) 2014 Rob Rix. All rights reserved.
public struct Identifier: Comparable, Hashable, Printable {
public init(graph: Graph<Node>) {
value = graph.nodes.isEmpty ? 0 : maxElement(graph.nodes.keys).value + 1
}
public init() {
self.value = Identifier.cursor++
}
// MARK: Endpoint constructors
p... |
Add dependency to the main target. `objc_retainAutoreleasedReturnValue` will be required even if compiled with release-mode. note: "libdispatch" has an implementation of `objc_retainAutoreleasedReturnValue`. This modification would be unnecessary when linking libdispatch. | // swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
#if os(Linux)
let linux = true
#else
let linux = false
#endif
var targets: [Target] = [
// Targets are the basic building blocks of a package. A target can define a... | // swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
#if os(Linux)
let linux = true
#else
let linux = false
#endif
var targets: [Target] = [
// Targets are the basic building blocks of a package. A target can define a... |
Improve the product line check and add support for the iPhone lines. | //
// Device
// Thingy
//
// Created by Bojan Dimovski on 19/01/2020.
// Copyright Β© 2020 Bojan Dimovski. All rights reserved.
//
import Foundation
public extension Device {
/// Product line of the model, currently supported only for the iPad.
var productLine: ProductLine? {
switch self {
case .iPad2,
... | //
// Device
// Thingy
//
// Created by Bojan Dimovski on 19/01/2020.
// Copyright Β© 2020 Bojan Dimovski. All rights reserved.
//
import Foundation
public extension Device {
/// Product line of the model, currently supported only for the iPad.
var productLine: ProductLine? {
switch family {
case .pad:
s... |
Move transactions with 0 timestamp to top of list | //
// Wallet+ViewModels.swift
// breadwallet
//
// Created by Adrian Corscadden on 2017-01-12.
// Copyright Β© 2017 breadwallet LLC. All rights reserved.
//
import Foundation
import BRCore
extension BRWallet {
func makeTransactionViewModels(blockHeight: UInt32) -> [Transaction] {
return transactions.fl... | //
// Wallet+ViewModels.swift
// breadwallet
//
// Created by Adrian Corscadden on 2017-01-12.
// Copyright Β© 2017 breadwallet LLC. All rights reserved.
//
import Foundation
import BRCore
extension BRWallet {
func makeTransactionViewModels(blockHeight: UInt32) -> [Transaction] {
return transactions.fl... |
Use Collection return value in ChordExtension | // Copyright (c) 2015 Ben Guo. All rights reserved.
import Foundation
extension Chord {
/// Creates a new `Harmonizer` using the (1-indexed) indices of the given harmonizer
public static func create(_ harmonizer: Harmonizer, indices: [UInt]) -> Harmonizer {
if indices.count < 2 || indices.contains(0)... | // Copyright (c) 2015 Ben Guo. All rights reserved.
import Foundation
extension Chord {
/// Creates a new `Harmonizer` using the (1-indexed) indices of the given harmonizer
public static func create(_ harmonizer: Harmonizer, indices: [UInt]) -> Harmonizer {
if indices.count < 2 || indices.contains(0)... |
Extend CellIdentifier to extract from table view cell | //
// CellIdentifiable.swift
// ZamzamKit
//
// Created by Basem Emara on 4/28/17.
// Copyright Β© 2017 Zamzam. All rights reserved.
//
import UIKit
public protocol CellIdentifiable {
associatedtype CellIdentifier: RawRepresentable
}
public extension CellIdentifiable where Self: UITableViewController, CellIde... | //
// CellIdentifiable.swift
// ZamzamKit
//
// Created by Basem Emara on 4/28/17.
// Copyright Β© 2017 Zamzam. All rights reserved.
//
import UIKit
public protocol CellIdentifiable {
associatedtype CellIdentifier: RawRepresentable
}
public extension CellIdentifiable where Self: UITableViewController, CellIde... |
Update solution to Decode Ways | /**
* Question Link: https://leetcode.com/problems/decode-ways/
* Primary idea: Dynamic Programming, dp[i] = dp[i - 1] + dp[i - 2],
* determine if current one or two characters are number at first
* Time Complexity: O(n), Space Complexity: O(n)
*
*/
class DecodeWays {
func numDecodings(_ s: St... | /**
* Question Link: https://leetcode.com/problems/decode-ways/
* Primary idea: Dynamic Programming, dp[i] = dp[i - 1] + dp[i - 2],
* determine if current one or two characters are number at first
* Time Complexity: O(n), Space Complexity: O(n)
*
*/
class DecodeWays {
func numDecodings(_ s: St... |
Add qualified import of Result in the test | // RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/linker)
// RUN: %target-build-swift -emit-module -c %S/Inputs/library.swift -o %t/linker/library.o
// RUN: %target-build-swift -emit-library -c %S/Inputs/library.swift -o %t/linker/library.o
// RUN: %target-build-swift %S/main.swift %t/linker/library.o -I %t/lin... | // RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/linker)
// RUN: %target-build-swift -emit-module -c %S/Inputs/library.swift -o %t/linker/library.o
// RUN: %target-build-swift -emit-library -c %S/Inputs/library.swift -o %t/linker/library.o
// RUN: %target-build-swift %S/main.swift %t/linker/library.o -I %t/lin... |
Revert "add exit call when done running" | class SemverIncrementer {
func usage() {
print("usage: origin-version $incrementBy")
print("e.g. semver-incrementer 0.6.6 9")
}
func run(args: [String]) {
guard args.count > 2 else {
useGit()
return
}
useInput(args)
exit(0)
}
... | class SemverIncrementer {
func usage() {
print("usage: origin-version $incrementBy")
print("e.g. semver-incrementer 0.6.6 9")
}
func run(args: [String]) {
guard args.count > 2 else {
useGit()
return
}
useInput(args)
}
func useInput(ar... |
Add discardableResult attributes to setters for user defaults | //
// UserDefaults.swift
// P3Foundation
//
// Created by Oscar Swanros on 6/15/16.
// Copyright Β© 2016 Pacific3. All rights reserved.
//
private let userDefaults = UserDefaults.standard()
extension UserDefaults {
// MARK: - Get Values
static func p3_getString(key: String) -> String {
let s = user... | //
// UserDefaults.swift
// P3Foundation
//
// Created by Oscar Swanros on 6/15/16.
// Copyright Β© 2016 Pacific3. All rights reserved.
//
private let userDefaults = UserDefaults.standard()
extension UserDefaults {
// MARK: - Get Values
static func p3_getString(key: String) -> String {
let s = user... |
Make Blobfish error configuration public | //
// Nodes.swift
// Nodes
//
// Created by Kasper Welner on 18/03/16.
// Copyright Β© 2016 Nodes. All rights reserved.
//
import Foundation
import Blobfish
public struct BlobfishConfiguration {
static func errorCodeMapping() -> [Int : Blobfish.AlamofireConfig.ErrorCategory] {
return [
441 ... | //
// Nodes.swift
// Nodes
//
// Created by Kasper Welner on 18/03/16.
// Copyright Β© 2016 Nodes. All rights reserved.
//
import Foundation
import Blobfish
public struct BlobfishConfiguration {
public static func errorCodeMapping() -> [Int : Blobfish.AlamofireConfig.ErrorCategory] {
return [
... |
Fix test compilation re: transformError | // Shirley
// Written in 2015 by Nate Stedman <nate@natestedman.com>
//
// To the extent possible under law, the author(s) have dedicated all copyright and
// related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.
//
// You should have recei... | // Shirley
// Written in 2015 by Nate Stedman <nate@natestedman.com>
//
// To the extent possible under law, the author(s) have dedicated all copyright and
// related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.
//
// You should have recei... |
Add test for status new | import XCTest
class TMHomeStrategyFactory:XCTestCase
{
}
| import XCTest
@testable import gattaca
class TMHomeStrategyFactory:XCTestCase
{
private var controller:CHome?
private var session:MSession?
override func setUp()
{
super.setUp()
let session:MSession = MSession()
self.session = session
controller = ... |
Add blank row at top | //
// ConfigViewController.swift
// Patriot
//
// Created by Ron Lisle on 5/29/17.
// Copyright Β© 2017 Ron Lisle. All rights reserved.
//
import UIKit
class ConfigViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func closeMenu(sender: Any... | //
// ConfigViewController.swift
// Patriot
//
// Created by Ron Lisle on 5/29/17.
// Copyright Β© 2017 Ron Lisle. All rights reserved.
//
import UIKit
class ConfigViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func closeMenu(sender: Any... |
Complete demo with workable pedometer. | //
// ViewController.swift
// CoreMotionDemo
//
// Created by BJ Miller on 8/6/14.
// Copyright (c) 2014 Six Five Software, LLC. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var stepCountLabel: UILabel!
@IBOutlet weak var distanceLabel: UILabel!
@IB... | //
// ViewController.swift
// CoreMotionDemo
//
// Created by BJ Miller on 8/6/14.
// Copyright (c) 2014 Six Five Software, LLC. All rights reserved.
//
import UIKit
import CoreMotion
class ViewController: UIViewController {
let pedometer = CMPedometer()
var lastDistance = 0.0
var lastUpdatedDate... |
Make the combined changeable mutable so we can use it with the binding context | //
// CombinedChangeable.swift
// SwiftRebound
//
// Created by Andrew Hunter on 12/07/2016.
//
//
import Foundation
///
/// Changeable implementation that works by combined many changeable objects into one
///
internal class CombinedChangeable : Changeable {
/// The chageables that are combined in this one
... | //
// CombinedChangeable.swift
// SwiftRebound
//
// Created by Andrew Hunter on 12/07/2016.
//
//
import Foundation
///
/// Changeable implementation that works by combined many changeable objects into one
///
internal class CombinedChangeable : Changeable {
/// The chageables that are combined in this one
... |
Add @noescape attribute to `each` function's closure | //
// ArrayUtils.swift
// QuickJump
//
// Created by Victor Shamanov on 5/29/15.
// Copyright (c) 2015 Victor Shamanov. All rights reserved.
//
import Foundation
extension Array {
var decomposed: (T, [T])? {
return isEmpty ? nil : (first!, Array(dropFirst(self)))
}
func each(f: T -> ... | //
// ArrayUtils.swift
// QuickJump
//
// Created by Victor Shamanov on 5/29/15.
// Copyright (c) 2015 Victor Shamanov. All rights reserved.
//
import Foundation
extension Array {
var decomposed: (T, [T])? {
return isEmpty ? nil : (first!, Array(dropFirst(self)))
}
func each(@noescap... |
Add binarySearch extension to Array | import Foundation
// http://stackoverflow.com/questions/31904396/swift-binary-search-for-standard-array
extension Array {
/// Finds such index N that predicate is true for all elements up to
/// but not including the index N, and is false for all elements
/// starting with index N.
/// Behavior is unde... | |
Add minimal test case for rdar://problem/54580427. | // FIXME: This should be linear instead of exponential.
// RUN: %scale-test --begin 1 --end 10 --step 1 --select NumLeafScopes --invert-result %s
// REQUIRES: OS=macosx
// REQUIRES: asserts
enum Val {
case d([String: Val])
case f(Double)
}
struct X {
var x : Float
}
extension X {
func val() -> Val {
retu... | |
Add basic SwiftPM manifest file for iOS | // swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "RxGesture",
products: [
.library(name: "RxGesture", targets: ["RxGesture"])
],
targets: [
.target(
name: "RxGesture",
path: "Pod",
exclude: ["Pod/Classes/OSX"]
... | |
Add test case for crash triggered in swift::constraints::ConstraintSystem::assignFixedType(swift::TypeVariableType*, swift::Type, bool) | // RUN: not --crash %target-swift-frontend %s -parse
// REQUIRES: asserts
// Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// Test case found by fuzzing
{println(""""?struct{
| |
Split the initialization test cases into their own file. | // RUN: rm -rf %t/clang-module-cache
// RUN: %swift %clang-importer-sdk -emit-sil -module-cache-path %t/clang-module-cache -I %S/Inputs/custom-modules -target x86_64-apple-darwin13 %s -verify
// RUN: ls -lR %t/clang-module-cache | grep ObjectiveC.pcm
import AppKit
import objc_ext
import TestProtocols
import ObjCParseE... | |
Add a solution to Flatten Binary Tree to Linked List | /**
* Question Link: https://leetcode.com/problems/flatten-binary-tree-to-linked-list/
* Primary idea: Reset left to nil and change current node to left child every time
* Time Complexity: O(n), Space Complexity: O(1)
*
* Definition for a binary tree node.
* public class TreeNode {
* public var val: Int
* ... | |
Add a simple ClassBasedOnClickListener example to the StoryboardExample project | //
// ExampleFolioReaderContainer
// StoryboardExample
//
// Created by Panajotis Maroungas on 18/08/16.
// Copyright Β© 2016 FolioReader. All rights reserved.
//
import UIKit
import FolioReaderKit
class ExampleFolioReaderContainer: FolioReaderContainer {
required init?(coder aDecoder: NSCoder) {
super.i... | //
// ExampleFolioReaderContainer
// StoryboardExample
//
// Created by Panajotis Maroungas on 18/08/16.
// Copyright Β© 2016 FolioReader. All rights reserved.
//
import UIKit
import FolioReaderKit
class ExampleFolioReaderContainer: FolioReaderContainer {
required init?(coder aDecoder: NSCoder) {
super.i... |
Move IEEE754 support into its own file | enum IEEEFloatingPointClass {
case SignalingNaN
case QuietNaN
case NegativeInfinity
case NegativeNormal
case NegativeSubnormal
case NegativeZero
case PositiveZero
case PositiveSubnormal
case PositiveNormal
case PositiveInfinity
}
extension IEEEFloatingPointClass : Equatable {}
func ==(lhs: IEEEFlo... | |
Extend `Data` with `func readData(toByte byte:UInt8, maximumLength:Int = Int.max) -> Data`. | /***************************************************************************************************
FileHandle+ReadDataToByte.swift
Β© 2017 YOCKOW.
Licensed under MIT License.
See "LICENSE.txt" for more information.
*****************************************************************************************... | |
Add test case for crash triggered in swift::Expr::propagateLValueAccessKind(swift::AccessKind, bool) | // RUN: not --crash %target-swift-frontend %s -parse
// REQUIRES: asserts
// Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// Test case found by fuzzing
class g{deinit{{&.T
| |
Add two way binding operator | //
// TextfieldBinding.swift
// Pods
//
// Created by Jakub OlejnΓk on 28/06/2017.
//
//
import ReactiveSwift
infix operator <~> : BindingPrecedence
public func <~> (property: MutableProperty<String?>, textField: UITextField) {
textField.reactive.text <~ property
property <~ textField.reactive.continuousT... | |
Test the ObserveTest's runBeforeEachChild method | //
// WhenRunningBeforeAndAfterChildrenBlockFromATestObject.swift
// Observe
//
// Created by Sam Meech-Ward on 2016-12-09.
//
//
@testable import Observe
import XCTest
class WhenRunningBeforeAndAfterChildrenBlockFromATestObject: XCTestCase {
var observeTest: ObserveTest!
override func setUp() {
... | |
Add π₯ case (π’ β 51, π β 5090) triggered in swift::createDesignatedInitOverride(β¦) | // This source file is part of the Swift.org open source project
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list... | |
Add test case for leak fixed by my SILGenPattern work. | // RUN: %target-run-simple-swift
// REQUIRES: executable_test
import StdlibUnittest
// Make sure that in the following code we do not leak the case of the enum.
protocol MyProtocol {}
// An enum that wraps LeakingClass
enum LeakingEnum1: MyProtocol {
case eNone1
case eLeakingClass1(LifetimeTracked)
}
// An enum t... | |
Add Service/Characteristic Identifiers for easier use | //
// CarSmartsService.swift
// SmartCar
//
// Created by Robert Smith on 4/30/17.
// Copyright Β© 2017 Robert Smith. All rights reserved.
//
import Foundation
import RxBluetoothKit
import CoreBluetooth
enum CarSmartsService: String, ServiceIdentifier {
case smartLock = "A1A4C256-3370-4D9A-99AA-70BFA81B906B"
... | |
Add test case for crash triggered in swift::constraints::ConstraintGraph::addConstraint(swift::constraints::Constraint*) | // RUN: not --crash %target-swift-frontend %s -parse
// REQUIRES: asserts
// Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// Test case found by fuzzing
let a{
var f=[[
map class d
{
protocol A:A
{
typealias d
class A:A
func a
cl... | |
Create area item ground prot | //
// MOptionTamalesOaxaquenosAreaItemGroundProtocol.swift
// miniMancera
//
// Created by zero on 7/14/17.
// Copyright Β© 2017 iturbide. All rights reserved.
//
import Foundation
| |
Add a test for serialization under optimizations. | // RUN: rm -rf %t && mkdir -p %t
// RUN: %swift -O -emit-module -o %t %s
// At one point this triggered deserialization of enough of the stdlib to cause
// an assertion failure in serialization.
class Rdar17567391 {
let data: [Int] = []
}
| |
Add test case for crash triggered in swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) | // RUN: not --crash %target-swift-frontend %s -parse
// REQUIRES: asserts
// Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// Test case found by fuzzing
class B<h{var d={struct d{typealias e:B
let t:e,A
| |
Add test that converts a .swiftinterface to .swiftmodule and uses it. | // RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/modulecache)
// RUN: %target-swift-frontend -enable-resilience -emit-parseable-module-interface-path %t/TestModule.swiftinterface -module-name TestModule %S/Inputs/other.swift -emit-module -o /dev/null
// RUN: test -f %t/TestModule.swiftinterface
// RUN: %target-... | |
Add a new extension that tint UIImage | //
// UIImageExtension.swift
// Rocket.Chat
//
// Created by Rafael K. Streit on 8/16/16.
// Copyright Β© 2016 Rocket.Chat. All rights reserved.
//
import UIKit
extension UIImage {
func imageWithTint(color: UIColor, alpha: CGFloat = 1.0) -> UIImage {
UIGraphicsBeginImageContextWithOptions(self.size, f... | |
Add basic SwiftPM manifest file | // swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "MBProgressHUD",
products: [
.library(name: "MBProgressHUD", targets: ["MBProgressHUD"])
],
targets: [
.target(
name: "MBProgressHUD",
path: ".",
exclude: ["Demo"],
... | |
Add tests for URLProtectionSpace.description property | // This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the l... | |
Add logic for getting files lines. | import Foundation
let path = FileManager.default.currentDirectoryPath
let file = "\(path)/Sources/game_configurations.txt"
do {
let gameConfigurations: String = try String(
contentsOfFile: file,
encoding: String.Encoding.utf8
)
var lines = gameConfigurations.components(separatedBy: "\n")
// remove u... | |
Add solution for 137. Single Number II. | /**
* Question Link: https://leetcode.com/problems/single-number-ii/
* Primary idea: Every number has 64 bits, for the i-th bit of each number.
* In total, we should have (nums.count) 0s and 1s.
* If the i-th bit of the single number is 1, then we should have (3n + 1) 1s, and (3n) 0s.
*... | |
Add test case for crash triggered in swift::IterativeTypeChecker::processInheritedProtocols(swift::ProtocolDecl*, llvm::function_ref<bool (swift::TypeCheckRequest)>) | // RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
// REQUIRES: asserts
protocol e:A.a
class A{
protocol c:e
func a<H:A.c func a#^A^# | |
Add test case for crash triggered in swift::ValueDecl::setType(swift::Type) | // RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
// REQUIRES: asserts
protocol P{struct X{let a={class d:a{class B<b:a{#^A^# | |
Add test case for crash triggered in swift::BoundGenericType::getSubstitutions(swift::ModuleDecl*, swift::LazyResolver*, swift::DeclContext*) | // RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
class A<h{#^A^#class B<a{let:AnyObject.Type=B | |
Add a SwiftPM 4 version of the manifest. | // swift-tools-version:4.0
// Package.swift
//
// Copyright (c) 2014 - 2017 Apple Inc. and the project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See LICENSE.txt for license information:
// https://github.com/apple/swift-protobuf/blob/master/LICENSE.txt
//
import PackageDescrip... | |
Add cache manager by Swiftful Thinking | //
// CacheManager.swift
// FetchJsonEscapable
//
// Created by Alexander Farber on 05.05.21.
//
class CacheManager {
static let instance = CacheManager()
private init()
var imageCache: NSCache<NSString, UIImage> = {
let cache = NSCache<NSString, UIImage>()
cache.countLimit = 100
... | |
Add test case for crash triggered in swift::Expr::propagateLValueAccessKind(swift::AccessKind, bool) | // RUN: not --crash %target-swift-frontend %s -parse
// REQUIRES: asserts
// Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// Test case found by fuzzing
let e=[[[]_
| |
Add App Store page presenting for SwiftUI | //
// StoreSheet.swift
// ZamzamUI
//
// Created by Basem Emara on 2021-08-07.
// Copyright Β© 2021 Zamzam Inc. All rights reserved.
//
#if os(iOS) && canImport(StoreKit)
import StoreKit
import SwiftUI
public extension View {
/// Presents iTunes Store product information using the given App Store parameters.
... | |
Add test case for crash triggered in swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) | // This source file is part of the Swift.org open source project
// See http://swift.org/LICENSE.txt for license information
// RUN: not --crash %target-swift-frontend %s -parse
!(0^_{
| |
Add a test for a crasher that was reported. | // RUN: not --crash %target-typecheck-verify-swift
extension Dictionary {
func doSomething<T>() -> [T : Value] {
let pairs: [(T, Value)] = []
return Dictionary(uniqueKeysWithValues: pairs)
}
}
| |
Add accessors for rows and columns | //
// MatrixRowsAndColumns.swift
// SwiftNum
//
// Created by Donald Pinckney on 1/4/17.
//
//
public extension Matrix {
// Returns an array of row vectors
var rows: [Matrix] {
return (0..<height).map { self[$0, 0..<width] }
}
// Return an array of column vectors
var columns: [Matri... | |
Add tests for DeepL integration | @testable import BartyCrouchTranslator
import Foundation
import Microya
import XCTest
class DeeplTranslatorApiTests: XCTestCase {
func testTranslate() {
let apiKey = "" // TODO: load from environment variable
guard !apiKey.isEmpty else { return }
let endpoint = DeeplApi.translate(
... | |
Move parameter extraction to userdefaults extension in separate file | //
// UserDefaults+LaunchParameters.swift
// Callisto
//
// Created by Patrick Kladek on 02.08.19.
// Copyright Β© 2019 IdeasOnCanvas. All rights reserved.
//
import Foundation
extension UserDefaults {
enum Action: String, CaseIterable {
case summarize
case upload
case unknown
}
... | |
Add regression test for substituting type var into template | // THIS-TEST-SHOULD-NOT-COMPILE
// Regression test for compiler internal error where we substitute invalid
// type into typevar
// NOTE: if we allow passing structs into TCL code directly, will need
// to modify test
type test {
int a;
int b;
}
<T> puts (T t) "turbine" "0.0.0" [
"puts <<t>>"
];
main () {
t... | |
Create a new PlayScene object with the same size of the current scene | import SpriteKit
class GameScene: SKScene {
// Play button node
let playButton = SKSpriteNode(imageNamed: "play")
override func didMoveToView(view: SKView) {
// Position the play button in the middle of the screen
// It position the button in the middle of the frame.
self.playB... | import SpriteKit
class GameScene: SKScene {
// Play button node
let playButton = SKSpriteNode(imageNamed: "play")
override func didMoveToView(view: SKView) {
// Position the play button in the middle of the screen
// It position the button in the middle of the frame.
self.playB... |
Add an executable test for checking the correctness of let properties optimizations. | // RUN: rm -rf %t && mkdir -p %t
// RUN: %target-build-swift -O %s -o %t/a.out
// RUN: %target-run %t/a.out | FileCheck %s -check-prefix=CHECK-OUTPUT
// REQUIRES: executable_test
// Check that in optimized builds the compiler generates correct code for
// initializations of let properties, which is assigned multipe t... | |
Add compiler crasher from SR-5825 | // RUN: not --crash %target-swift-frontend %s -emit-ir
struct DefaultAssociatedType {
}
protocol Protocol {
associatedtype AssociatedType = DefaultAssociatedType
init(object: AssociatedType)
}
final class Conformance: Protocol {
private let object: AssociatedType
init(object: AssociatedType) {
... | |
Add fixed crasher for rdar://problem/30154791. | // RUN: not %target-swift-frontend %s -typecheck
struct X<T> {}
struct Y<T> {}
protocol P {
associatedtype T = X<U>
associatedtype U
func foo() -> T
}
protocol Q: P {
func bar() -> T
func bas() -> U
}
extension P {
func foo() -> X<U> { fatalError() }
}
extension Q {
func foo() -> Y<U> { fatalError()... | |
Add test case for crash triggered in swift::constraints::ConstraintSystem::simplify(bool) | // RUN: not --crash %target-swift-frontend %s -parse
// Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// Test case found by fuzzing
{struct b{let a{struct D{let a=b([print{}}}}struct b
| |
Add test case for crash triggered in swift::TypeChecker::applyUnboundGenericArguments(swift::UnboundGenericType*, swift::SourceLoc, swift::DeclContext*, llvm::MutableArrayRef<swift::TypeLoc>, bool, swift::GenericTypeResolver*) | // RUN: not --crash %target-swift-frontend %s -parse
// REQUIRES: asserts
// Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// Test case found by fuzzing
class B<T{func a{{func g:A}protocol A{typealias e=c<T>struct c<a]typealias d... | |
Put ProfilePageView in an UIViewController | //
// ProfileViewController.swift
// Markit
//
// Created by rrao on 10/13/16.
// Copyright Β© 2016 Victor Frolov. All rights reserved.
//
import Foundation
| |
Add an execution test for extensions to CF types. | // RUN: %target-run-simple-swift | FileCheck %s
import Foundation
#if os(OSX)
import AppKit
#endif
#if os(iOS)
import UIKit
#endif
extension CGColorSpace {
class func deviceRGB() -> CGColorSpace {
return CGColorSpaceCreateDeviceRGB()
}
}
extension CGColor {
class func create(#colorSpace: CGColorSpace, #c... | |
Add temporary comment depth indicator. | import UIKit
import WMF
// TODO
final class TalkPageCellCommentDepthIndicator: SetupView {
let depth: Int
let label = UILabel()
required init(depth: Int) {
self.depth = depth
super.init(frame: .zero)
setup()
}
required init?(coder aDecoder: NSCoder) {
fatalError()... | |
Add test file for fast completion | class Foo {
var x: Int
var y: Int
func fooMethod() {}
}
struct Bar {
var a: Int
var b: Int
func barMethod() {}
}
func foo(arg: Foo) {
_ = arg.
}
func bar(arg: Bar) {
_ = arg.
}
// NOTE: Tests for 'key.codecomplete.reuseastcontex' option.
// RUN: %sourcekitd-test \
// RUN: -req=track-compiles == \
//... | |
Add UIGestureRecognizer property for isEnabled. | /*
Copyright 2016-present The Material Motion Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by appl... | |
Add basic SwifPM manifest file | // swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "Motion",
// platforms: [.iOS("8.0")],
products: [
.library(name: "Motion", targets: ["Motion"])
],
targets: [
.target(
name: "Motion",
path: "Sources"
)
]
)
| |
Add new Swift compiler crash with extension of generic type with type alias | import Foundation;
public protocol HasReflect {
typealias T : HasReflect
static func reflect() -> Type<T>
}
public protocol JsonSerializable : HasReflect, StringSerializable {
}
public protocol StringSerializable {
typealias T
static func fromString(string:String) -> T?
}
public class TypeAccessor {}
... | |
Set the location for the m map using CLLocationCoordinate2D | import UIKit
import MapKit
class ViewController: UIViewController, MKMapViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Add the longitude and latitude
var longitude:CLLocationDegrees = 98.3
var latitude:CLLocationDegrees = 21... | import UIKit
import MapKit
class ViewController: UIViewController, MKMapViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Add the longitude and latitude
var longitude:CLLocationDegrees = 98.3
var latitude:CLLocationDegrees = 21... |
Add regression test for rdar://59496033 | // RUN: %target-swift-emit-silgen %s | %FileCheck %s
// REQUIRES: objc_interop
import Foundation
import CoreGraphics
let _: (CFURL) -> CGDataProvider? = CGDataProvider.init
// CHECK-LABEL: sil private [ossa] @$s15cf_curried_initSo17CGDataProviderRefaSgSo8CFURLRefacfu_ : $@convention(thin) (@guaranteed CFURL) -> @ow... | |
Drop _ObjectiveCBridgeable since swift-corelibs-foundation transacts upon non-objc clases | // This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the l... | // This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the l... |
Add test case for crash triggered in swift::TypeChecker::checkInheritanceClause(swift::Decl*, swift::GenericTypeResolver*) | // RUN: not --crash %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
// REQUIRES: asserts
struct S<e{let e={func d<T{{enum a:e)#^A^# | |
Add trivial test for IR generation of the getter/setter for a property. | // RUN: %swift -triple x86_64-apple-darwin10 -I %S/.. %s -emit-llvm | FileCheck %s
import swift
var _x : Int = 0;
var x : Int {
// CHECK: define i64 @_T10properties__get1xFT_NSs5Int64
get { return -_x; }
// CHECK: define void @_T10properties__set1xFT5valueNSs5Int64_T_
set { _x = value + 1; }
}
func f() ->Int ... | |
Add enum representing Results that may fail with an ErrorType | //
// ResultType.swift
// WolframAlpha
//
// Created by Roman Roibu on 8/29/15.
// Copyright Β© 2015 Roman Roibu. All rights reserved.
//
import Foundation
public enum Result<SuccessType> {
case Success(SuccessType)
case Failure(ErrorType)
public var value: SuccessType? {
switch self {
... | |
Update delegate flow without [weak self] | //
// DelegateHelper.swift
// Mockingjay
//
// Created by Tien Nhat Vu on 5/17/18.
//
import Foundation
/// Use this object to remove the needs of [unowned self] or [weak self] in closure delegate callback
public struct DelegateHelper<I, O> {
private(set) var handler: ((I) -> O?)?
public init() {... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.