TryRemoveAllOptionals.yql 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. (
  2. (let config (DataSource 'config))
  3. (let world (Configure! world config 'PureDataSource 'yt))
  4. (let res_sink (DataSink 'result))
  5. ### Tuple
  6. # (Int8?, String?, (Int32, Int64)?) (success)
  7. (let value '((Just (Int8 '1)) (Just (String 'str)) (Just '((Int32 '2) (Int64 '3)))))
  8. (let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value))
  9. (let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type))))
  10. # (Int8?, String, (Int32, Int64)?) (success)
  11. (let value '((Just (Int8 '1)) (String 'str) (Just '((Int32 '2) (Int64 '3)))))
  12. (let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value))
  13. (let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type))))
  14. # (Int8?, Nothing(String?), (Int32, Int64)?) (fail)
  15. (let value '((Just (Int8 '1)) (Nothing (OptionalType (DataType 'String))) (Just '((Int32 '2) (Int64 '3)))))
  16. (let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value))
  17. (let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type))))
  18. # () (success)
  19. (let value '())
  20. (let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value))
  21. (let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type))))
  22. ### Struct
  23. # Struct<Int8?, String?, (Int32, Int64)?> (success)
  24. (let value (AsStruct '('a (Just (Int8 '1))) '('b (Just (String 'str))) '('c (Just '((Int32 '2) (Int64 '3))))))
  25. (let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value))
  26. (let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type))))
  27. # Struct<Int8?, String, (Int32, Int64)?> (success)
  28. (let value (AsStruct '('a (Just (Int8 '1))) '('b (String 'str)) '('c (Just '((Int32 '2) (Int64 '3))))))
  29. (let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value))
  30. (let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type))))
  31. # Struct<Int8?, Nothing(String?), (Int32, Int64)?> (fail)
  32. (let value (AsStruct '('a (Just (Int8 '1))) '('b (Nothing (OptionalType (DataType 'String)))) '('c (Just '((Int32 '2) (Int64 '3))))))
  33. (let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value))
  34. (let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type))))
  35. # Struct<> (success)
  36. (let value (Struct))
  37. (let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value))
  38. (let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type))))
  39. (let world (Commit! world res_sink))
  40. (return world)
  41. )