diff --git a/js/test_cases/_type_casting/README.md b/js/test_cases/_type_casting/README.md new file mode 100644 index 0000000..397e086 --- /dev/null +++ b/js/test_cases/_type_casting/README.md @@ -0,0 +1,3 @@ +Type casting appears to work on referenced values as well as literals. Do I add a separate type cast function or push the entire implementation of the helpers off into the traits? If I'm supporting custom helpers in the future I'll need to push off the helper implementation eventually anyway. + +What other types are available? All I see referenced in the docs is "number". diff --git a/js/test_cases/_type_casting/input1.json b/js/test_cases/_type_casting/input1.json new file mode 100644 index 0000000..113c7b5 --- /dev/null +++ b/js/test_cases/_type_casting/input1.json @@ -0,0 +1,4 @@ +{ + "str": "7", + "int": 7 +} diff --git a/js/test_cases/_type_casting/main.dust b/js/test_cases/_type_casting/main.dust new file mode 100644 index 0000000..69207b9 --- /dev/null +++ b/js/test_cases/_type_casting/main.dust @@ -0,0 +1,5 @@ +{@eq key=str value="7"}str is equal to "7"{:else}str does not equal "7"{/eq}{~n} +{@eq key=int value="7"}int is equal to "7"{:else}int does not equal "7"{/eq}{~n} +{@eq key=int value="7" type="number"}int is equal to "7"::number{:else}int does not equal "7"::number{/eq}{~n} +{@eq key=int value=str}int is equal to str{:else}int does not equal str{/eq}{~n} +{@eq key=int value=str type="number"}int is equal to str::number{:else}int does not equal str::number{/eq}{~n}