aboutsummaryrefslogtreecommitdiff
path: root/tests/expression_test.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2017-10-31 16:07:04 +0100
committerSébastien Dailly <sebastien@chimrod.com>2017-10-31 16:07:04 +0100
commitab721136f50914a21f6cca89f0fcfb055ba58cd2 (patch)
tree60f788e3e8733a6d3606e801bc21a24e419e070e /tests/expression_test.ml
parentdb627ca2cfc745bbf2e489251e64054ab2b3bff9 (diff)
parentd8ed0babfa1c03c8f1968443a465972bb3bf460c (diff)
Update ScTypes.types with types used in evaluator
Diffstat (limited to 'tests/expression_test.ml')
-rwxr-xr-xtests/expression_test.ml29
1 files changed, 20 insertions, 9 deletions
diff --git a/tests/expression_test.ml b/tests/expression_test.ml
index 3f00e67..0950383 100755
--- a/tests/expression_test.ml
+++ b/tests/expression_test.ml
@@ -6,11 +6,11 @@ let u = UTF8.from_utf8string
let _msg ~expected ~result =
let get_type = function
- | Expression.Basic ScTypes.Num _ -> "N"
- | Expression.Basic ScTypes.Str _ -> "S"
- | Expression.Basic ScTypes.Date _ -> "D"
- | Expression.Basic ScTypes.Bool _ -> "B"
- | Expression.Formula _ -> "F" in
+ | Expression.Basic ScTypes.Num (ScTypes.Number, _) -> "N"
+ | Expression.Basic ScTypes.Num (ScTypes.Date, _) -> "D"
+ | Expression.Basic ScTypes.Str _ -> "S"
+ | Expression.Basic ScTypes.Bool _ -> "B"
+ | Expression.Formula _ -> "F" in
Printf.sprintf "Expected %s:%s but got %s:%s"
(UTF8.raw_encode @@ Expression.show expected)
@@ -52,7 +52,10 @@ end
let test_num ctx = begin
let result = Expression.load @@ u"123" in
let expected = Expression.load_expr @@ Expression.Basic (
- ScTypes.Num (Num.num_of_int 123, None)) in
+ ScTypes.Num (
+ ScTypes.Number,
+ DataType.Num.of_num @@ Num.num_of_int 123
+ )) in
assert_equal expected result
end
@@ -60,21 +63,29 @@ let test_float ctx = begin
let result = Expression.load @@ u"12.45" in
let expected = Expression.load_expr @@ Expression.Basic (
ScTypes.Num (
- T.Num.of_float_string "12.45", None)) in
+ ScTypes.Number,
+ DataType.Num.of_num @@ T.Num.of_float_string "12.45"
+ )) in
assert_equal expected result
end
let test_relative ctx = begin
let result = Expression.load @@ u"-123" in
let expected = Expression.load_expr @@ Expression.Basic (
- ScTypes.Num (Num.num_of_int (-123), None)) in
+ ScTypes.Num (
+ ScTypes.Number,
+ DataType.Num.of_num @@ Num.num_of_int (-123)
+ )) in
assert_equal expected result
end
let test_date ctx = begin
let result = Expression.load @@ u"1900/01/01"
and expected = Expression.load_expr @@ Expression.Basic (
- ScTypes.Date (Tools.Date.get_julian_day 1900 01 01)) in
+ ScTypes.Num (
+ ScTypes.Date,
+ DataType.Num.of_num @@ Date.get_julian_day 1900 01 01
+ )) in
assert_equal expected result
end