|
1 | 1 | // This test file has been translated from swift/test/Parse/generic_disambiguation.swift
|
2 | 2 |
|
| 3 | +import SwiftSyntax |
| 4 | + |
3 | 5 | import XCTest
|
4 | 6 |
|
5 | 7 | final class GenericDisambiguationTests: XCTestCase {
|
@@ -54,36 +56,93 @@ final class GenericDisambiguationTests: XCTestCase {
|
54 | 56 | )
|
55 | 57 | }
|
56 | 58 |
|
57 |
| - func testGenericDisambiguation6() { |
| 59 | + func testGenericDisambiguation6a() { |
58 | 60 | AssertParse(
|
59 | 61 | """
|
60 | 62 | _ = a < b
|
| 63 | + """ |
| 64 | + ) |
| 65 | + } |
| 66 | + |
| 67 | + func testGenericDisambiguation6b() { |
| 68 | + AssertParse( |
| 69 | + """ |
61 | 70 | _ = (a < b, c > d)
|
62 |
| - // Parses as generic because of lparen after '>' |
63 |
| - (a < b, c > (d)) |
64 |
| - // Parses as generic because of lparen after '>' |
65 |
| - (a<b, c>(d)) |
| 71 | + """ |
| 72 | + ) |
| 73 | + } |
| 74 | + |
| 75 | + func testGenericDisambiguation6c() { |
| 76 | + // Parses as generic because of lparen after '>' |
| 77 | + AssertParse( |
| 78 | + """ |
| 79 | + (a < b, c > (d)) |
| 80 | + """, |
| 81 | + substructure: Syntax(GenericArgumentListSyntax([ |
| 82 | + GenericArgumentSyntax( |
| 83 | + argumentType: TypeSyntax(SimpleTypeIdentifierSyntax( |
| 84 | + name: .identifier("b"), |
| 85 | + genericArgumentClause: nil |
| 86 | + )), |
| 87 | + trailingComma: .commaToken() |
| 88 | + ), |
| 89 | + GenericArgumentSyntax( |
| 90 | + argumentType: TypeSyntax(SimpleTypeIdentifierSyntax( |
| 91 | + name: .identifier("c"), |
| 92 | + genericArgumentClause: nil |
| 93 | + )), |
| 94 | + trailingComma: nil |
| 95 | + ) |
| 96 | + ])) |
| 97 | + ) |
| 98 | + } |
| 99 | + |
| 100 | + func testGenericDisambiguation6d() { |
| 101 | + // Parses as generic because of lparen after '>' |
| 102 | + AssertParse( |
| 103 | + """ |
| 104 | + (a<b, c>(d)) |
| 105 | + """, |
| 106 | + substructure: Syntax(GenericArgumentListSyntax([ |
| 107 | + GenericArgumentSyntax( |
| 108 | + argumentType: TypeSyntax(SimpleTypeIdentifierSyntax( |
| 109 | + name: .identifier("b"), |
| 110 | + genericArgumentClause: nil |
| 111 | + )), |
| 112 | + trailingComma: .commaToken() |
| 113 | + ), |
| 114 | + GenericArgumentSyntax( |
| 115 | + argumentType: TypeSyntax(SimpleTypeIdentifierSyntax( |
| 116 | + name: .identifier("c"), |
| 117 | + genericArgumentClause: nil |
| 118 | + )), |
| 119 | + trailingComma: nil |
| 120 | + ) |
| 121 | + ])) |
| 122 | + ) |
| 123 | + } |
| 124 | + |
| 125 | + func testGenericDisambiguation6e() { |
| 126 | + AssertParse( |
| 127 | + """ |
66 | 128 | _ = a>(b)
|
| 129 | + """ |
| 130 | + ) |
| 131 | + } |
| 132 | + |
| 133 | + func testGenericDisambiguation6f() { |
| 134 | + AssertParse( |
| 135 | + """ |
67 | 136 | _ = a > (b)
|
68 |
| - """, |
69 |
| - diagnostics: [ |
70 |
| - // TODO: Old parser expected error on line 4: cannot specialize a non-generic definition |
71 |
| - // TODO: Old parser expected note on line 4: while parsing this '<' as a type parameter bracket |
72 |
| - // TODO: Old parser expected error on line 6: cannot specialize a non-generic definition |
73 |
| - // TODO: Old parser expected note on line 6: while parsing this '<' as a type parameter bracket |
74 |
| - ] |
| 137 | + """ |
75 | 138 | )
|
76 | 139 | }
|
77 | 140 |
|
78 | 141 | func testGenericDisambiguation7() {
|
79 | 142 | AssertParse(
|
80 | 143 | """
|
81 | 144 | generic<Int>(0)
|
82 |
| - """, |
83 |
| - diagnostics: [ |
84 |
| - // TODO: Old parser expected error on line 1: cannot explicitly specialize a generic function |
85 |
| - // TODO: Old parser expected note on line 1: while parsing this '<' as a type parameter bracket |
86 |
| - ] |
| 145 | + """ |
87 | 146 | )
|
88 | 147 | }
|
89 | 148 |
|
|
0 commit comments