-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Labels
Description
Run these tests, compiles fine, but when you run them, casting errors or failing. Using v7.0.1
module secure1.TestRunner.Tests.FsUnitRuntimeErrors
open System
open Xunit
open FsUnit.Xunit
[<Fact>]
let ``String contains causes runtime cast error`` () =
let message = "Hello World"
message |> should contain "World"
[<Fact>]
let ``Mixed type comparison causes runtime error`` () =
let value = 43L
value |> should be (greaterThan 42)
[<Fact>]
let ``Empty sequence comparison causes runtime error`` () =
let emptyList = []
emptyList |> should equal List.empty<int>
And the result
secure1.TestRunner.Tests test failed with 3 error(s) (1.8s)
D:\a\_work\1\s\src\FSharp.Core\prim-types.fs(721): error TESTERROR:
secure1.TestRunner.Tests.FsUnitRuntimeErrors.String contains causes runtime cast error (23ms): Error Message: System.InvalidCastException : Unable to cast object of type 'System.Char' to type 'System.String'.
Stack Trace:
at Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicFunctions.UnboxGeneric[T](Object source) in D:\a\_work\1\s\src\FSharp.Core\prim-types.fs:line 721
at Microsoft.FSharp.Collections.IEnumerator.cast@26.System.Collections.Generic.IEnumerator<'T>.get_Current() in D:\a\_work\1\s\src\FSharp.Core\seqcore.fs:line 27
at Microsoft.FSharp.Collections.SeqModule.Exists[T](FSharpFunc`2 predicate, IEnumerable`1 source) in D:\a\_work\1\s\src\FSharp.Core\seq.fs:line 677
at [email protected](Object delegateArg0)
at NHamcrest.Core.CustomMatcher`1.Matches(T item)
at FsUnit.Xunit.Assert.That.Static[a](a actual, IMatcher`1 matcher)
at secure1.TestRunner.Tests.FsUnitRuntimeErrors.String contains causes runtime cast error() in C:\data6\fs\Cascade\secureit1\tests\secure1.TestRunner.Tests\FsUnitRuntimeErrors.fs:line 10
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
C:\data6\fs\Cascade\secureit1\tests\secure1.TestRunner.Tests\FsUnitRuntimeErrors.fs(15): error TESTERROR:
secure1.TestRunner.Tests.FsUnitRuntimeErrors.Mixed type comparison causes runtime error (2ms): Error Message: System.ArgumentException : Object must be of type Int64.
Stack Trace:
at System.Int64.CompareTo(Object value)
at [email protected](Object delegateArg0)
at NHamcrest.Core.CustomMatcher`1.Matches(T item)
at FsUnit.Xunit.Assert.That.Static[a](a actual, IMatcher`1 matcher)
at secure1.TestRunner.Tests.FsUnitRuntimeErrors.Mixed type comparison causes runtime error() in C:\data6\fs\Cascade\secureit1\tests\secure1.TestRunner.Tests\FsUnitRuntimeErrors.fs:line 15
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
C:\data6\fs\Cascade\secureit1\tests\secure1.TestRunner.Tests\FsUnitRuntimeErrors.fs(20): error TESTERROR:
secure1.TestRunner.Tests.FsUnitRuntimeErrors.Empty sequence comparison causes runtime error (10ms): Error Message: Assert.Equal() Failure: Values differ
Expected: Equals []
Actual: []
Stack Trace:
at FsUnit.Xunit.raiseEqualException@16[b](StringDescription description, String value)
at FsUnit.Xunit.Assert.That.Static[a](a actual, IMatcher`1 matcher)
at secure1.TestRunner.Tests.FsUnitRuntimeErrors.Empty sequence comparison causes runtime error() in C:\data6\fs\Cascade\secureit1\tests\secure1.TestRunner.Tests\FsUnitRuntimeErrors.fs:line 20
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Test summary: total: 3, failed: 3, succeeded: 0, skipped: 0, duration: 1.8s
Build failed with 3 error(s) and 1 warning(s) in 8.3s