1import Foundation
2
3class LineAppender {
4    func parse(_ string: String) -> String {
5        var result = ""
6        var lineNumber = 1
7        for line in string.components(separatedBy: "\n") {
8            result += "\(lineNumber) \(line)\n"
9            lineNumber += 1
10        }
11        return String(result.dropLast())
12    }
13} 
14Description:
15LineAppender is an object that has a `parse(_ string: String) -> String` function.
16It takes a string and will be responsible for prefix each line of the string
17with its current line number.
18The method returns the transformed string.
19You must thus implement the object `LineAppender`
20and all the apis invoked in following unit tests that act as specs
21import Foundation
22func test_line_appender() {
23	let sut = LineAppender()
24	
25	let input = """
26	func helloWorld() {
27		print("hello world")
28	}
29	
30	helloWorld()
31	"""
32	
33	let output = sut.parse(input)
34	
35	let expectedOutput = """
36	1 func helloWorld() {
37	2	print("hello world")
38	3 }
39	4
40	5 helloWorld()
41	"""
42	
43	print("Current output: \(output)")
44	assert(output == expectedOutput)
45}
46
47test_line_appender()
main/lineappender.swift.no-extension:44: Assertion failed
Stack dump:
0.	Program arguments: /Library/Developer/CommandLineTools/usr/bin/swift-frontend -frontend -interpret /var/folders/m9/xbnrbp5d1qb1pm_45jmsr5380000gn/T/lineappender.swift.no-extension -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -new-driver-path /Library/Developer/CommandLineTools/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Library/Developer/CommandLineTools/usr/lib/swift -module-name main -disable-clang-spi -target-sdk-version 15.4 -target-sdk-name macosx15.4 -external-plugin-path /Library/Developer/Developer/usr/lib/swift/host/plugins#/Library/Developer/Developer/usr/bin/swift-plugin-server -external-plugin-path /Library/Developer/Developer/usr/local/lib/swift/host/plugins#/Library/Developer/Developer/usr/bin/swift-plugin-server -in-process-plugin-server-path /Library/Developer/CommandLineTools/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Library/Developer/CommandLineTools/usr/lib/swift/host/plugins -plugin-path /Library/Developer/CommandLineTools/usr/local/lib/swift/host/plugins
1.	Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
2.	Compiling with effective version 5.10
3.	While running user code "/var/folders/m9/xbnrbp5d1qb1pm_45jmsr5380000gn/T/lineappender.swift.no-extension"
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000106ddac28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000106dd8a60 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000106ddb264 SignalHandler(int) + 360
3  libsystem_platform.dylib 0x0000000183373624 _sigtramp + 56
4  libswiftCore.dylib       0x00000001947b21f8 $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF + 176
5  libswiftCore.dylib       0x000000010ff3c2a0 $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF + 18446744071486087512
6  libswiftCore.dylib       0x000000010ff3c010 $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF + 18446744071486086856
7  swift-frontend           0x0000000100d814a4 llvm::orc::runAsMain(int (*)(int, char**), llvm::ArrayRef, std::__1::allocator>>, std::__1::optional) + 908
8  swift-frontend           0x0000000100c97850 swift::SwiftJIT::runMain(llvm::ArrayRef, std::__1::allocator>>) + 628
9  swift-frontend           0x0000000100ca4c3c swift::RunImmediately(swift::CompilerInstance&, std::__1::vector, std::__1::allocator>, std::__1::allocator, std::__1::allocator>>> const&, swift::IRGenOptions const&, swift::SILOptions const&, std::__1::unique_ptr>&&) + 1052
10 swift-frontend           0x0000000100c31840 processCommandLineAndRunImmediately(swift::CompilerInstance&, std::__1::unique_ptr>&&, llvm::PointerUnion, swift::FrontendObserver*, int&) + 504
11 swift-frontend           0x0000000100c2cffc performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr>, llvm::PointerUnion, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1980
12 swift-frontend           0x0000000100c2c71c swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2688
13 swift-frontend           0x0000000100c2fe44 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 3796
14 swift-frontend           0x0000000100c2dfd8 swift::performFrontend(llvm::ArrayRef, char const*, void*, swift::FrontendObserver*) + 3716
15 swift-frontend           0x0000000100bb20bc swift::mainEntry(int, char const**) + 5428
16 dyld                     0x0000000182f9ab4c start + 6000