Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfafad3c

Browse files
committed
re-add tests
1 parentb914569 commitfafad3c

File tree

11 files changed

+122
-37
lines changed

11 files changed

+122
-37
lines changed

‎src/fsharp/FSharp.Core/printf.fs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ namespace Microsoft.FSharp.Core
44

55
typePrintfFormat<'Printer,'State,'Residue,'Result>(value:string)=
66
memberx.Value= value
7+
8+
override__.ToString()= value
79

810
typePrintfFormat<'Printer,'State,'Residue,'Result,'Tuple>(value:string)=
911
inherit PrintfFormat<'Printer,'State,'Residue,'Result>(value)

‎src/fsharp/FSharp.Core/printf.fsi‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ open System.Text
1515
/// <typeparam name="Residue">Value generated by the overall printf action (e.g. sprint generates a string)</typeparam>
1616
/// <typeparam name="Result">Value generated after post processing (e.g. failwithf generates a string internally then raises an exception)</typeparam>
1717
typePrintfFormat<'Printer,'State,'Residue,'Result>=
18+
1819
/// <summary>Construct a format string </summary>
1920
/// <param name="value">The input string.</param>
2021
/// <returns>The PrintfFormat containing the formatted result.</returns>
2122
new: value:string-> PrintfFormat<'Printer,'State,'Residue,'Result>
23+
2224
/// <summary>The raw text of the format string.</summary>
2325
memberValue:string
2426

@@ -29,7 +31,9 @@ type PrintfFormat<'Printer,'State,'Residue,'Result> =
2931
/// <typeparam name="Result">Value generated after post processing (e.g. failwithf generates a string internally then raises an exception)</typeparam>
3032
/// <typeparam name="Tuple">Tuple of values generated by scan or match.</typeparam>
3133
type PrintfFormat<'Printer,'State,'Residue,'Result,'Tuple>=
34+
3235
inherit PrintfFormat<'Printer,'State,'Residue,'Result>
36+
3337
/// <summary>Construct a format string</summary>
3438
/// <param name="value">The input string.</param>
3539
/// <returns>The created format string.</returns>
@@ -137,25 +141,27 @@ module Printf =
137141
/// <summary>Represents a statically-analyzed format associated with writing to a <c>System.Text.StringBuilder</c>. The first type parameter indicates the
138142
/// arguments of the format operation and the last the overall return type.</summary>
139143
typeBuilderFormat<'T,'Result>= Format<'T, StringBuilder, unit, 'Result>
144+
140145
/// <summary>Represents a statically-analyzed format when formatting builds a string. The first type parameter indicates the
141146
/// arguments of the format operation and the last the overall return type.</summary>
142147
typeStringFormat<'T,'Result>= Format<'T, unit, string, 'Result>
148+
143149
/// <summary>Represents a statically-analyzed format associated with writing to a <c>System.IO.TextWriter</c>. The first type parameter indicates the
144150
/// arguments of the format operation and the last the overall return type.</summary>
145151
typeTextWriterFormat<'T,'Result>= Format<'T, TextWriter, unit, 'Result>
146152

147153
/// <summary>Represents a statically-analyzed format associated with writing to a <c>System.Text.StringBuilder</c>. The type parameter indicates the
148154
/// arguments and return type of the format operation.</summary>
149155
typeBuilderFormat<'T>= BuilderFormat<'T,unit>
156+
150157
/// <summary>Represents a statically-analyzed format when formatting builds a string. The type parameter indicates the
151158
/// arguments and return type of the format operation.</summary>
152159
typeStringFormat<'T>= StringFormat<'T,string>
160+
153161
/// <summary>Represents a statically-analyzed format associated with writing to a <c>System.IO.TextWriter</c>. The type parameter indicates the
154162
/// arguments and return type of the format operation.</summary>
155163
typeTextWriterFormat<'T>= TextWriterFormat<'T,unit>
156164

157-
158-
159165
/// <summary>Print to a <c>System.Text.StringBuilder</c></summary>
160166
/// <param name="builder">The StringBuilder to print to.</param>
161167
/// <param name="format">The input formatter.</param>

‎tests/fsharp/tests.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,10 +2440,10 @@ module TypecheckTests =
24402440
let``type check neg104``()= singleNegTest(testConfig"typecheck/sigs")"neg104"
24412441

24422442
[<Test>]
2443-
let``type checkneg103``()= singleNegTest(testConfig"typecheck/sigs")"neg103"
2443+
let``type checkneg103b``()= singleNegTest(testConfig"typecheck/sigs")"neg103b"
24442444

24452445
[<Test>]
2446-
let``type checkneg104``()= singleNegTest(testConfig"typecheck/sigs")"neg104"
2446+
let``type checkneg104b``()= singleNegTest(testConfig"typecheck/sigs")"neg104b"
24472447

24482448
[<Test>]
24492449
let``type check neg_anon_1``()= singleNegTest(testConfig"typecheck/sigs")"neg_anon_1"
Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11

2-
neg103.fs(5,50,5,61): typecheck error FS0001: Two anonymous record types have mismatched sets of field names '["a"; "b"]' and '["a"]'
3-
4-
neg103.fs(7,41,7,52): typecheck error FS0001: Two anonymous record types have mismatched sets of field names '["b"]' and '["a"]'
5-
6-
neg103.fs(10,27,10,55): typecheck error FS0059: The type '{|a : int|}' does not have any proper subtypes and need not be used as the target of a static coercion
7-
8-
neg103.fs(10,27,10,55): typecheck error FS0193: Type constraint mismatch. The type
9-
'{|b : int|}'
10-
is not compatible with type
11-
'{|a : int|}'
12-
13-
14-
neg103.fs(13,27,13,62): typecheck error FS0059: The type '{|a : int|}' does not have any proper subtypes and need not be used as the target of a static coercion
15-
16-
neg103.fs(13,27,13,62): typecheck error FS0193: Type constraint mismatch. The type
17-
'{|a : int ; b : int|}'
18-
is not compatible with type
19-
'{|a : int|}'
20-
21-
22-
neg103.fs(18,34,18,36): typecheck error FS0001: The type '('a -> 'a)' does not support the 'comparison' constraint. For example, it does not support the 'System.IComparable' interface
23-
24-
neg103.fs(20,42,20,44): typecheck error FS0001: The type '('a -> 'a)' does not support the 'comparison' constraint. For example, it does not support the 'System.IComparable' interface
2+
neg103.fs(7,12,7,22): typecheck error FS0001: This expression was expected to have type
3+
'Async<'a>'
4+
but here has type
5+
'string'
6+
7+
neg103.fs(12,7,12,15): typecheck error FS0001: This expression was expected to have type
8+
'int'
9+
but here has type
10+
'MyUnion'
11+
12+
neg103.fs(17,7,17,15): typecheck error FS0001: This expression was expected to have type
13+
'int'
14+
but here has type
15+
'MyUnion'
16+
17+
neg103.fs(21,7,21,9): typecheck error FS0001: This expression was expected to have type
18+
'Async<int>'
19+
but here has type
20+
'int'
21+
22+
neg103.fs(25,11,25,19): typecheck error FS0001: This expression was expected to have type
23+
'int'
24+
but here has type
25+
'MyUnion'
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
neg103.fs(5,50,5,61): typecheck error FS0001: Two anonymous record types have mismatched sets of field names '["a";"b"]'and '["a"]'
3+
4+
neg103.fs(7,41,7,52): typecheck error FS0001: Two anonymous record types have mismatched sets of field names '["b"]'and '["a"]'
5+
6+
neg103.fs(10,27,10,55): typecheck error FS0059: The type '{|a : int|}' doesnot have any proper subtypesand neednot be used as the target of a static coercion
7+
8+
neg103.fs(10,27,10,55): typecheck error FS0193: Type constraint mismatch. The type
9+
'{|b : int|}'
10+
isnot compatible with type
11+
'{|a : int|}'
12+
13+
14+
neg103.fs(13,27,13,62): typecheck error FS0059: The type '{|a : int|}' doesnot have any proper subtypesand neednot be used as the target of a static coercion
15+
16+
neg103.fs(13,27,13,62): typecheck error FS0193: Type constraint mismatch. The type
17+
'{|a : int; b : int|}'
18+
isnot compatible with type
19+
'{|a : int|}'
20+
21+
22+
neg103.fs(18,34,18,36): typecheck error FS0001: The type '('a-> 'a)' doesnot support the 'comparison' constraint.For example, it doesnot support the 'System.IComparable' interface
23+
24+
neg103.fs(20,42,20,44): typecheck error FS0001: The type '('a-> 'a)' doesnot support the 'comparison' constraint.For example, it doesnot support the 'System.IComparable' interface
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
moduleM
3+
4+
// Check we get compile-time errors
5+
letnegTypeTest1()=({| a=1+1; b=2|}={| a=2|})
6+
7+
letnegTypeTest2()=({| b=2|}={| a=2|})
8+
9+
// no subsumption
10+
letnegTypeTest3()=({| b=2|}:>{| a: int|})
11+
12+
// no subsumption
13+
letnegTypeTest4()=({| b=2; a=1|}:>{| a: int|})
14+
15+
letposgTypeTest5()=({| b=2; a=1|}={| a=1; b=2|})
16+
17+
// Comparison is not possible if structural elements are comparable
18+
letnegTypeTest6()=({| a= id|}>{| a= id|})
19+
20+
letnegTypeTest7()=(compare{| a= id|}{| a= id|})

‎tests/fsharp/typecheck/sigs/neg104.bsl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ neg104.fs(32,27,32,28): parse error FS0604: Unmatched '{'
1717

1818
neg104.fs(35,19,35,20): parse error FS0010: Unexpected symbol '}'in definition. Expected incomplete structured construct ator before this pointor other token.
1919

20-
neg104.fs(35,1,35,20): parse error FS0010: Incomplete structured construct ator before this pointin implementation file
20+
neg104.fs(36,1,36,1): parse error FS0010: Incomplete structured construct ator before this pointin implementation file

‎tests/fsharp/typecheck/sigs/neg104.vsbsl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ neg104.fs(32,27,32,28): parse error FS0604: Unmatched '{'
1717

1818
neg104.fs(35,19,35,20): parse error FS0010: Unexpected symbol '}' in definition. Expected incomplete structured construct at or before this point or other token.
1919

20-
neg104.fs(35,1,35,20): parse error FS0010: Incomplete structured construct at or before this point in implementation file
20+
neg104.fs(36,1,36,1): parse error FS0010: Incomplete structured construct at or before this point in implementation file
2121

2222
neg104.fs(8,9,8,30): typecheck error FS0750: This construct may only be used within computation expressions
2323

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
neg104b.fs(6,38,6,39): parse error FS0010: Unexpected symbol '}'in binding. Expected '|}'or other token.
3+
4+
neg104b.fs(6,29,6,31): parse error FS0605: Unmatched '{|'
5+
6+
neg104b.fs(8,5,8,8): parse error FS0058: Possible incorrect indentation: this token is offside of context started at position (6:29).Try indenting this token furtheror using standard formatting conventions.
7+
8+
neg104b.fs(10,5,10,9): parse error FS0058: Possible incorrect indentation: this token is offside of context started at position (8:5).Try indenting this token furtheror using standard formatting conventions.
9+
10+
neg104b.fs(10,5,10,9): parse error FS0010: Unexpected keyword 'type'in binding. Expected incomplete structured construct ator before this pointor other token.
11+
12+
neg104b.fs(6,5,6,8): parse error FS3118: Incomplete valueor function definition.If this isin an expression, the body of the expression must be indentedto the same column as the 'let' keyword.
13+
14+
neg104b.fs(10,25,10,26): parse error FS0010: Unexpected symbol '}'in type definition. Expected '|}'or other token.
15+
16+
neg104b.fs(10,14,10,16): parse error FS0605: Unmatched '{|'
17+
18+
neg104b.fs(12,5,12,8): parse error FS0058: Possible incorrect indentation: this token is offside of context started at position (10:14).Try indenting this token furtheror using standard formatting conventions.
19+
20+
neg104b.fs(14,1,14,1): parse error FS0010: Incomplete structured construct ator before this pointin implementation file
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
moduleM
3+
4+
5+
// Check we get parsing error and decent recovery
6+
letnegParsingTest2()={| b=2}
7+
8+
letnormalCode1()=()
9+
// Check we get parsing error and decent recovery
10+
typeX={| A:int}
11+
12+
letnormalCode2()=()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp