|
| 1 | +import Symbols |
| 2 | +import Testing |
| 3 | + |
| 4 | +@Suite |
| 5 | +enum Parsing |
| 6 | +{ |
| 7 | + @Test |
| 8 | + static func Empty() |
| 9 | + { |
| 10 | + #expect(nil == Symbol.USR.init("")) |
| 11 | + } |
| 12 | + @Test |
| 13 | + static func EmptySuffix() |
| 14 | + { |
| 15 | + #expect(nil == Symbol.USR.init("s:")) |
| 16 | + } |
| 17 | + |
| 18 | + @Test |
| 19 | + static func Scalar() |
| 20 | + { |
| 21 | + let expected:Symbol.Decl = .init(.s, ascii: "s12IdentifiableP") |
| 22 | + #expect(Symbol.USR.init("s:s12IdentifiableP") == .scalar(expected)) |
| 23 | + } |
| 24 | + @Test |
| 25 | + static func ScalarInvalidLanguage() |
| 26 | + { |
| 27 | + #expect(nil == Symbol.USR.init("ss:s12IdentifiableP")) |
| 28 | + } |
| 29 | + @Test |
| 30 | + static func ScalarInvalidCharacters() |
| 31 | + { |
| 32 | + #expect(nil == Symbol.USR.init("s:s12Identifi ableP")) |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + static func Compound() |
| 37 | + { |
| 38 | + let expected:Symbol.Decl.Vector = .init(.init(.s, ascii: """ |
| 39 | + s12IdentifiablePsRlzCrlE2idSOvp |
| 40 | + """), |
| 41 | + self: .init(.s, ascii: "Sq")) |
| 42 | + #expect(Symbol.USR.init( |
| 43 | + "s:s12IdentifiablePsRlzCrlE2idSOvp::SYNTHESIZED::s:Sq") == .vector(expected)) |
| 44 | + } |
| 45 | + @Test |
| 46 | + static func CompoundInvalidPrefix() |
| 47 | + { |
| 48 | + #expect(nil == Symbol.USR.init( |
| 49 | + ":s12IdentifiablePsRlzCrlE2idSOvp::SYNTHESIZED::s:Sq")) |
| 50 | + } |
| 51 | + @Test |
| 52 | + static func CompoundInvalidInfix() |
| 53 | + { |
| 54 | + #expect(nil == Symbol.USR.init( |
| 55 | + "s:s12IdentifiablePsRlzCrlE2idSOvp::LASERTITTIES::s:Sq")) |
| 56 | + } |
| 57 | + @Test |
| 58 | + static func CompoundInvalidSuffix() |
| 59 | + { |
| 60 | + #expect(nil == Symbol.USR.init( |
| 61 | + "s:s12IdentifiablePsRlzCrlE2idSOvp::SYNTHESIZED::s:")) |
| 62 | + } |
| 63 | + |
| 64 | + @Test |
| 65 | + static func MacroDollarIdentifier() |
| 66 | + { |
| 67 | + let expected:Symbol.Decl.Vector = .init(.init(.s, ascii: """ |
| 68 | + 9FluentKit5ModelPAAE4_$idAA10IDPropertyCyx7IDValueQzGvp |
| 69 | + """), |
| 70 | + self: .init(.s, ascii: "17HummingbirdFluent12PersistModelC")) |
| 71 | + |
| 72 | + #expect(Symbol.USR.init(""" |
| 73 | + s:9FluentKit5ModelPAAE4_$idAA10IDPropertyCyx7IDValueQzGvp\ |
| 74 | + ::SYNTHESIZED::s:17HummingbirdFluent12PersistModelC |
| 75 | + """) == .vector(expected)) |
| 76 | + } |
| 77 | + |
| 78 | + @Test |
| 79 | + static func ObjectiveC() |
| 80 | + { |
| 81 | + let expected:Symbol.Decl = .init(.c, ascii: """ |
| 82 | + @CM@Alamofire@objc(cs)SessionDelegate(im)URLSession\ |
| 83 | + :webSocketTask:didOpenWithProtocol: |
| 84 | + """) |
| 85 | + #expect(Symbol.USR.init(""" |
| 86 | + c:@CM@Alamofire@objc(cs)SessionDelegate(im)URLSession\ |
| 87 | + :webSocketTask:didOpenWithProtocol: |
| 88 | + """) == .scalar(expected)) |
| 89 | + } |
| 90 | + |
| 91 | + @Test |
| 92 | + static func Chimaeric() |
| 93 | + { |
| 94 | + let expected:Symbol.Decl.Vector = .init(.init(.s, ascii: "SQsE2neoiySbx_xtFZ"), |
| 95 | + self: .init(.c, ascii: "@E@memory_order")) |
| 96 | + #expect(Symbol.USR.init(""" |
| 97 | + s:SQsE2neoiySbx_xtFZ::SYNTHESIZED::c:@E@memory_order |
| 98 | + """) == .vector(expected)) |
| 99 | + } |
| 100 | + |
| 101 | + @Test |
| 102 | + static func BlockFirstMember() |
| 103 | + { |
| 104 | + #expect(Symbol.USR.init(""" |
| 105 | + s:e:s:Sq17ZooExtensionsDeepSiRszlE2ids5NeverOvp |
| 106 | + """) == .block(.init(name: "s:Sq17ZooExtensionsDeepSiRszlE2ids5NeverOvp"))) |
| 107 | + } |
| 108 | + @Test |
| 109 | + static func BlockFirstConformance() |
| 110 | + { |
| 111 | + #expect(Symbol.USR.init(""" |
| 112 | + s:e:s:Sqs:s8SendableP |
| 113 | + """) == .block(.init(name: "s:Sqs:s8SendableP"))) |
| 114 | + } |
| 115 | + @Test |
| 116 | + static func BlockGibberish() |
| 117 | + { |
| 118 | + #expect(Symbol.USR.init("s:e: \n!\u{0} 🇺🇸") == .block(.init(name: " \n!\u{0} 🇺🇸"))) |
| 119 | + } |
| 120 | + @Test |
| 121 | + static func BlockEmpty() |
| 122 | + { |
| 123 | + #expect(Symbol.USR.init("s:e:") == .block(.init(name: ""))) |
| 124 | + } |
| 125 | +} |
0 commit comments