Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Checked =
[<Theory; FileInlineData("unchecked01.fs")>]
let ``fsc-unchecked - unchecked01_fs`` compilation =
compilation
|> getCompilation
|> getCompilation
|> asFs
|> compile
|> shouldSucceed
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Conformance.UnitsOfMeasure

open Xunit
open FSharp.Test
open FSharp.Test.Compiler

module Basic =
let shouldFailWithDiagnostics expectedDiagnostics compilation =
compilation
|> asLibrary
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withDiagnostics expectedDiagnostics

let shouldSucceed compilation =
compilation
|> asLibrary
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

[<FileInlineData("Calculus.fsx")>]
[<FileInlineData("Mars.fsx")>]
[<FileInlineData("MassForce.fsx")>]
[<FileInlineData("Misc01.fsx")>]
[<FileInlineData("Misc03.fsx")>]
[<FileInlineData("Misc04.fsx")>]
[<FileInlineData("Quotation04_hidden.fsx")>]
[<FileInlineData("RationalExponents01.fsx")>]
[<FileInlineData("Stats.fsx")>]
[<FileInlineData("SI.fsx")>]
[<Theory>]
let ``Basic - shouldSucceed`` compilation =
compilation
|> getCompilation
|> shouldSucceed

[<Theory; FileInlineData("E_MassForce.fsx")>]
let ``Basic - E_MassForce`` compilation =
compilation
|> getCompilation
|> shouldFailWithDiagnostics [
(Error 1, Line 15, Col 27, Line 15, Col 32, "The unit of measure 'N' does not match the unit of measure 'kg'")
(Error 43, Line 15, Col 25, Line 15, Col 26, "The unit of measure 'N' does not match the unit of measure 'kg'")
]

[<Theory; FileInlineData("Misc02.fsx")>]
let ``Basic - Misc02_fs`` compilation =
compilation
|> getCompilation
|> shouldFailWithDiagnostics [
(Warning 64, Line 36, Col 60, Line 36, Col 61, "This construct causes code to be less generic than indicated by the type annotations. The unit-of-measure variable 'v has been constrained to be measure ''u/'w'.")
]
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let rec newton (f:float<_> -> float<_>) f' x xacc =
else newton f f' x' xacc

// Non-regular datatype: a list of derivatives of a function
[<NoComparison;NoEquality>]
type derivs<[<Measure>] 'u, [<Measure>] 'v> =
Nil
| Cons of (float<'u> -> float<'v>) * derivs<'u,'v/'u>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ let r2 = (polyadd (new ComplexProd()))

let weird(x:float<'u 'w>) (y:float<'v 'w>) (z:float<'w/'u 'v>) = 1

if (r/1.0<kg> = 14.0) && (r2/1.0<kg> = 28.0) then exit 0 else 1
(if (r/1.0<kg> = 14.0) && (r2/1.0<kg> = 28.0) then 0 else 1) |> ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Conformance.UnitsOfMeasure

open Xunit
open FSharp.Test
open FSharp.Test.Compiler

module Bounds =
let shouldFailWithDiagnostics expectedDiagnostics compilation =
compilation
|> asLibrary
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withDiagnostics expectedDiagnostics


[<Theory; FileInlineData("infinity_01.fsx")>]
let ``infinity_01_fsx`` compilation =
compilation
|> getCompilation
|> shouldFailWithDiagnostics [
(Error 717, Line 12, Col 18, Line 12, Col 27, "Unexpected type arguments")
(Error 717, Line 13, Col 18, Line 13, Col 26, "Unexpected type arguments")
(Error 717, Line 14, Col 19, Line 14, Col 28, "Unexpected type arguments")
(Error 717, Line 15, Col 19, Line 15, Col 27, "Unexpected type arguments")
]

[<Theory;FileInlineData("nan_01.fsx")>]
let ``nan_01_fsx`` compilation =
compilation
|> getCompilation
|> shouldFailWithDiagnostics [
(Error 717, Line 7, Col 19, Line 7, Col 22, "Unexpected type arguments")
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
#light
[<Measure>] type kg
let mysterymass = nan<kg>
exit 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Conformance.UnitsOfMeasure

open Xunit
open FSharp.Test
open FSharp.Test.Compiler

module Constants =
let shouldFailWithDiagnostics expectedDiagnostics compilation =
compilation
|> asLibrary
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldFail
|> withDiagnostics expectedDiagnostics

let shouldSucceed compilation =
compilation
|> asLibrary
|> withOptions ["--test:ErrorRanges"]
|> typecheck
|> shouldSucceed

[<FileInlineData("decimal.fsx")>]
[<FileInlineData("ieee32.fsx")>]
[<FileInlineData("ieee64.fsx")>]
[<FileInlineData("SpecialSyntax_.fsx")>]
[<Theory>]
let ``Constants - shouldSucceed`` compilation =
compilation
|> getCompilation
|> shouldSucceed

[<Theory; FileInlineData("E_UnsupportedTypes01.fsx")>]
let ``E_UnsupportedTypes01_fsx`` compilation =
compilation
|> getCompilation
|> shouldFailWithDiagnostics [
(Error 636, Line 22, Col 9, Line 22, Col 15, "Units-of-measure are only supported on float, float32, decimal, and integer types.")
(Error 636, Line 23, Col 9, Line 23, Col 15, "Units-of-measure are only supported on float, float32, decimal, and integer types.")
]

This file was deleted.

Loading