LoginSignup
2
1

More than 5 years have passed since last update.

F#でお気軽すぐるテスト

Last updated at Posted at 2019-04-07

IMG_2138.jpeg

へんにね
合わせすぎても
たぶん
つらいだけさ

Summary

おてがるテスト

Motivation

愛用してる perssimon.scripttravis で動作しなくなってるため、急遽書いた

like this

// かんたんチェッカー
let check  x y  =
  stdout.WriteLine " ----------------------------------- "
  if x = y then
    "OK" |> printfn "%A"
    x |> printfn "%A"
    y |> printfn "%A"
  else
    "NG" |> printfn "%A"
    x |> printfn "%A"
    y |> printfn "%A"
    raise (System.ArgumentException("===== NG =====") )

// --------------------------------------------------------
//                          使い方
// --------------------------------------------------------

// OK
check 1 1
check "foo" "foo"
check [1..10] [1..10]

// NG -> エラーを発生させる
check 1 2

結果


[Loading /Users/callmekohei/foo.fsx]
 ----------------------------------- 
"OK"
1
1
 ----------------------------------- 
"OK"
"foo"
"foo"
 ----------------------------------- 
"OK"
[1; 2; 3; 4; 5; 6; 7; 8; 9; 10]
[1; 2; 3; 4; 5; 6; 7; 8; 9; 10]
 ----------------------------------- 
"NG"
1
2
System.ArgumentException: ===== NG =====
  at FSI_0008.Foo.check[0] (a x, a y) [0x00108] in <062d34e0fb6f431f9681f515345f5230>:0 
  at <StartupCode$FSI_0008>.$FSI_0008_Foo$fsx.main@ () [0x00062] in <062d34e0fb6f431f9681f515345f5230>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0003b] in <547b0ab402754bd3aef2dcb174312979>:0 
Stopped due to error

*** time : 0.12656 s ***

まぁこれでいいのだ

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1