diff --git a/bool/bool.mbt b/bool/bool.mbt index 9cda9761..abe40a73 100644 --- a/bool/bool.mbt +++ b/bool/bool.mbt @@ -22,25 +22,25 @@ pub fn to_int(self : Bool) -> Int { pub fn to_int64(self : Bool) -> Int64 { if self { - 1L + 1 } else { - 0L + 0 } } pub fn to_uint(self : Bool) -> UInt { if self { - 1U + 1 } else { - 0U + 0 } } pub fn to_uint64(self : Bool) -> UInt64 { if self { - 1UL + 1 } else { - 0UL + 0 } } diff --git a/builtin/json.mbt b/builtin/json.mbt index c9d4a4b7..07956105 100644 --- a/builtin/json.mbt +++ b/builtin/json.mbt @@ -29,9 +29,9 @@ pub trait ToJson { pub fn Bool::to_json(self : Bool) -> Json { if self { - True + true } else { - False + false } } diff --git a/json/to_json_test.mbt b/json/to_json_test.mbt index 9fe5af51..a02d6427 100644 --- a/json/to_json_test.mbt +++ b/json/to_json_test.mbt @@ -144,29 +144,19 @@ test "Option::to_json" { ) } -// test "optinal field" { -// let opt = { x: Some(42), t: Some(Some(42)) } -// inspect!( -// opt.to_json(), -// content= -// #|Object({"x": Array([Number(42)]), "t": Array([Array([Number(42)])])}) -// , -// ) -// let opt = { x: None, t: None } -// inspect!( -// opt.to_json(), -// content= -// #|Object({"x": Null, "t": Null}) -// , -// ) -// let opt = { x: None, t: Some(None) } -// inspect!( -// opt.to_json(), -// content= -// #|Object({"x": Null, "t": Array([Null])}) -// , -// ) -// } +test "optional field" { + let opt = [ + { x: Some(42), t: Some(Some(42)) }, + { x: None, t: None }, + { x: None, t: Some(None) }, + ] + inspect!( + opt.to_json() |> @json.stringify, + content= + #|[{"x":42,"t":[42]},{},{"t":null}] + , + ) +} test "optional field round trip" { let opt = { x: Some(42), t: Some(Some(42)) } diff --git a/rational/rational_test.mbt b/rational/rational_test.mbt index cd59b4a9..f57d1f9b 100644 --- a/rational/rational_test.mbt +++ b/rational/rational_test.mbt @@ -107,9 +107,9 @@ test "from_double array" { let a : Array[Double] = [ 0.5, 5, 29.97, -29.97, 63.5, 126.5, 127.0, 127.5, -63.5, -126.5, -127.0, -127.5, ] - inspect_double_array!( - a, - content="[Ok(1/2), Ok(5), Ok(2997/100), Ok(-2997/100), Ok(127/2), Ok(253/2), Ok(127), Ok(255/2), Ok(-127/2), Ok(-253/2), Ok(-127), Ok(-255/2)]", + inspect!( + a.map(fn { x => @rational.from_double?(x).unwrap() }), + content="[1/2, 5, 2997/100, -2997/100, 127/2, 253/2, 127, 255/2, -127/2, -253/2, -127, -255/2]", ) let a = [ -10.0e200, 10.0e200, @double.infinity, @double.neg_infinity, @double.not_a_number,