YAMLでテストケースを書く2

  • テストケースを
- TestCaseNo: 1
  TestHTML:   test1.html
  Expect:     [1,2,undef]
  • のように書いてて、いくらやってもundefが来ないなーと思ったら「undef」という文字列リテラルが来てたということに時間かかって気づいた(>_<)
  • そういえばYAMLperlにとってのundef(未定義)な値は表現する方法あるのかしら?と思ったらあった。YAML::SyckでImplicitTypingフラグを1にしておいて「~」をセットすれば良い。

$YAML::Syck::ImplicitTyping
Defaults to false. Setting this to a true value will make Load recognize various implicit types in YAML, such as unquoted true, false, as well as integers and floating-point numbers. Otherwise, only ~ is recognized to be undef.

  • これでYAML::Syckでテスト書く時はImplicitTypingフラグは必須かもしれない。というわけで正解は
- TestCaseNo: 1
  TestHTML:   test1.html
  Expect:     [1,2,~]