Skip to content

Commit b6396b9

Browse files
authored
Use new multiline strings and normalize line ends (#183)
1 parent 3c780d4 commit b6396b9

1 file changed

Lines changed: 89 additions & 75 deletions

File tree

test/TypeDefsGeneratorTests.cs

Lines changed: 89 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,18 @@ private interface SimpleInterface
4646
[Fact]
4747
public void GenerateSimpleInterface()
4848
{
49-
// NOTE: String literals in these tests use TABS for indendation!
50-
Assert.Equal(@"
51-
/** interface */
52-
export interface SimpleInterface {
53-
/** property */
54-
TestProperty: string;
55-
56-
/** method */
57-
TestMethod(): string;
58-
}",
49+
// NOTE: String literals in these tests use TABS for indentation!
50+
Assert.Equal("""
51+
52+
/** interface */
53+
export interface SimpleInterface {
54+
/** property */
55+
TestProperty: string;
56+
57+
/** method */
58+
TestMethod(): string;
59+
}
60+
""".ReplaceLineEndings(),
5961
GenerateTypeDefinition(typeof(SimpleInterface), new Dictionary<string, string>
6062
{
6163
["T:SimpleInterface"] = "interface",
@@ -73,18 +75,20 @@ private class SimpleClass : SimpleInterface
7375
[Fact]
7476
public void GenerateSimpleClass()
7577
{
76-
Assert.Equal(@"
77-
/** class */
78-
export class SimpleClass {
79-
/** constructor */
80-
constructor();
81-
82-
/** property */
83-
TestProperty: string;
84-
85-
/** method */
86-
TestMethod(): string;
87-
}",
78+
Assert.Equal("""
79+
80+
/** class */
81+
export class SimpleClass {
82+
/** constructor */
83+
constructor();
84+
85+
/** property */
86+
TestProperty: string;
87+
88+
/** method */
89+
TestMethod(): string;
90+
}
91+
""".ReplaceLineEndings(),
8892
GenerateTypeDefinition(typeof(SimpleClass), new Dictionary<string, string>
8993
{
9094
["T:SimpleClass"] = "class",
@@ -117,9 +121,11 @@ public void GenerateSimpleMethod()
117121
[Fact]
118122
public void GenerateSimpleDelegate()
119123
{
120-
Assert.Equal(@"
121-
/** delegate */
122-
export interface SimpleDelegate { (arg: string): void; }",
124+
Assert.Equal("""
125+
126+
/** delegate */
127+
export interface SimpleDelegate { (arg: string): void; }
128+
""".ReplaceLineEndings(),
123129
GenerateTypeDefinition(typeof(SimpleDelegate), new Dictionary<string, string>
124130
{
125131
["T:SimpleDelegate"] = "delegate",
@@ -135,15 +141,17 @@ private enum TestEnum
135141
[Fact]
136142
public void GenerateEnum()
137143
{
138-
Assert.Equal(@"
139-
/** enum */
140-
export enum TestEnum {
141-
/** zero */
142-
Zero = 0,
143-
144-
/** one */
145-
One = 1,
146-
}",
144+
Assert.Equal("""
145+
146+
/** enum */
147+
export enum TestEnum {
148+
/** zero */
149+
Zero = 0,
150+
151+
/** one */
152+
One = 1,
153+
}
154+
""".ReplaceLineEndings(),
147155
GenerateTypeDefinition(typeof(TestEnum), new Dictionary<string, string>
148156
{
149157
["T:TestEnum"] = "enum",
@@ -161,22 +169,24 @@ private interface GenericInterface<T>
161169
[Fact]
162170
public void GenerateGenericInterface()
163171
{
164-
Assert.Equal(@"
165-
/** [Generic type factory] generic-interface */
166-
export function GenericInterface$(T: IType<any>): GenericInterface$$1<any>;
172+
Assert.Equal("""
167173
168-
/** generic-interface */
169-
export interface GenericInterface$$1<T> {
170-
}
174+
/** [Generic type factory] generic-interface */
175+
export function GenericInterface$(T: IType<any>): GenericInterface$$1<any>;
176+
177+
/** generic-interface */
178+
export interface GenericInterface$$1<T> {
179+
}
171180
172-
/** generic-interface */
173-
export interface GenericInterface$1<T> {
174-
/** instance-property */
175-
TestProperty: T;
181+
/** generic-interface */
182+
export interface GenericInterface$1<T> {
183+
/** instance-property */
184+
TestProperty: T;
176185
177-
/** instance-method */
178-
TestMethod(value: T): T;
179-
}",
186+
/** instance-method */
187+
TestMethod(value: T): T;
188+
}
189+
""".ReplaceLineEndings(),
180190
GenerateTypeDefinition(typeof(GenericInterface<>), new Dictionary<string, string>
181191
{
182192
["T:GenericInterface`1"] = "generic-interface",
@@ -197,30 +207,32 @@ private class GenericClass<T> : GenericInterface<T>
197207
[Fact]
198208
public void GenerateGenericClass()
199209
{
200-
Assert.Equal(@"
201-
/** [Generic type factory] generic-class */
202-
export function GenericClass$(T: IType<any>): GenericClass$$1<any>;
210+
Assert.Equal("""
203211
204-
/** generic-class */
205-
export interface GenericClass$$1<T> {
206-
/** constructor */
207-
new(value: T): GenericClass$1<T>;
212+
/** [Generic type factory] generic-class */
213+
export function GenericClass$(T: IType<any>): GenericClass$$1<any>;
208214
209-
/** static-property */
210-
TestStaticProperty: T;
215+
/** generic-class */
216+
export interface GenericClass$$1<T> {
217+
/** constructor */
218+
new(value: T): GenericClass$1<T>;
211219
212-
/** static-method */
213-
TestStaticMethod(value: T): T;
214-
}
220+
/** static-property */
221+
TestStaticProperty: T;
215222
216-
/** generic-class */
217-
export interface GenericClass$1<T> {
218-
/** instance-property */
219-
TestProperty: T;
223+
/** static-method */
224+
TestStaticMethod(value: T): T;
225+
}
220226
221-
/** instance-method */
222-
TestMethod(value: T): T;
223-
}",
227+
/** generic-class */
228+
export interface GenericClass$1<T> {
229+
/** instance-property */
230+
TestProperty: T;
231+
232+
/** instance-method */
233+
TestMethod(value: T): T;
234+
}
235+
""".ReplaceLineEndings(),
224236
GenerateTypeDefinition(typeof(GenericClass<>), new Dictionary<string, string>
225237
{
226238
["T:GenericClass`1"] = "generic-class",
@@ -237,17 +249,19 @@ export interface GenericClass$1<T> {
237249
[Fact]
238250
public void GenerateGenericDelegate()
239251
{
240-
Assert.Equal(@"
241-
/** [Generic type factory] generic-delegate */
242-
export function GenericDelegate$(T: IType<any>): GenericDelegate$$1<any>;
252+
Assert.Equal("""
243253
244-
/** generic-delegate */
245-
export interface GenericDelegate$$1<T> {
246-
new(func: (arg: T) => T): GenericDelegate$1<T>;
247-
}
254+
/** [Generic type factory] generic-delegate */
255+
export function GenericDelegate$(T: IType<any>): GenericDelegate$$1<any>;
256+
257+
/** generic-delegate */
258+
export interface GenericDelegate$$1<T> {
259+
new(func: (arg: T) => T): GenericDelegate$1<T>;
260+
}
248261
249-
/** generic-delegate */
250-
export interface GenericDelegate$1<T> { (arg: T): T; }",
262+
/** generic-delegate */
263+
export interface GenericDelegate$1<T> { (arg: T): T; }
264+
""".ReplaceLineEndings(),
251265
GenerateTypeDefinition(typeof(GenericDelegate<>), new Dictionary<string, string>
252266
{
253267
["T:GenericDelegate`1"] = "generic-delegate",

0 commit comments

Comments
 (0)