mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
test cases
This commit is contained in:
parent
f87ac88867
commit
e330b0642e
5 changed files with 16 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
module Luau.Syntax.FromJSON where
|
module Luau.Syntax.FromJSON where
|
||||||
|
|
||||||
open import Luau.Syntax using (Block; Stat ; Expr; nil; _$_; var; var_∈_; function_is_end; _⟨_⟩; local_←_; return; done; _∙_; maybe; VarDec; number; binexp; BinaryOperator; +; -; *; /)
|
open import Luau.Syntax using (Block; Stat ; Expr; nil; _$_; var; var_∈_; function_is_end; _⟨_⟩; local_←_; return; done; _∙_; maybe; VarDec; number; binexp; BinaryOperator; +; -; *; /; ≡; ≅; <; >; ≤; ≥)
|
||||||
open import Luau.Type.FromJSON using (typeFromJSON)
|
open import Luau.Type.FromJSON using (typeFromJSON)
|
||||||
|
|
||||||
open import Agda.Builtin.List using (List; _∷_; [])
|
open import Agda.Builtin.List using (List; _∷_; [])
|
||||||
|
@ -55,6 +55,12 @@ binOpFromString "Add" = Right +
|
||||||
binOpFromString "Sub" = Right -
|
binOpFromString "Sub" = Right -
|
||||||
binOpFromString "Mul" = Right *
|
binOpFromString "Mul" = Right *
|
||||||
binOpFromString "Div" = Right /
|
binOpFromString "Div" = Right /
|
||||||
|
binOpFromString "CompareEq" = Right ≡
|
||||||
|
binOpFromString "CompareNe" = Right ≅
|
||||||
|
binOpFromString "CompareLt" = Right <
|
||||||
|
binOpFromString "CompareLe" = Right ≤
|
||||||
|
binOpFromString "CompareGt" = Right >
|
||||||
|
binOpFromString "CompareGe" = Right ≥
|
||||||
binOpFromString s = Left ("'" ++ s ++ "' is not a valid operator")
|
binOpFromString s = Left ("'" ++ s ++ "' is not a valid operator")
|
||||||
|
|
||||||
varDecFromJSON (object arg) = varDecFromObject arg
|
varDecFromJSON (object arg) = varDecFromObject arg
|
||||||
|
@ -103,6 +109,11 @@ exprFromObject obj | just (string "AstExprConstantNumber") with lookup value obj
|
||||||
exprFromObject obj | just (string "AstExprConstantNumber") | just (FFI.Data.Aeson.Value.number x) = Right (number (toFloat x))
|
exprFromObject obj | just (string "AstExprConstantNumber") | just (FFI.Data.Aeson.Value.number x) = Right (number (toFloat x))
|
||||||
exprFromObject obj | just (string "AstExprConstantNumber") | just _ = Left "AstExprConstantNumber value is not a number"
|
exprFromObject obj | just (string "AstExprConstantNumber") | just _ = Left "AstExprConstantNumber value is not a number"
|
||||||
exprFromObject obj | just (string "AstExprConstantNumber") | nothing = Left "AstExprConstantNumber missing value"
|
exprFromObject obj | just (string "AstExprConstantNumber") | nothing = Left "AstExprConstantNumber missing value"
|
||||||
|
exprFromObject obj | just (string "AstExprConstantBool") with lookup value obj
|
||||||
|
exprFromObject obj | just (string "AstExprConstantBool") | just (FFI.Data.Aeson.Value.bool true) = Right Expr.true
|
||||||
|
exprFromObject obj | just (string "AstExprConstantBool") | just (FFI.Data.Aeson.Value.bool false) = Right Expr.false
|
||||||
|
exprFromObject obj | just (string "AstExprConstantBool") | just _ = Left "AstExprConstantBool value is not a bool"
|
||||||
|
exprFromObject obj | just (string "AstExprConstantBool") | nothing = Left "AstExprConstantBool missing value"
|
||||||
exprFromObject obj | just (string "AstExprBinary") with lookup op obj | lookup left obj | lookup right obj
|
exprFromObject obj | just (string "AstExprBinary") with lookup op obj | lookup left obj | lookup right obj
|
||||||
exprFromObject obj | just (string "AstExprBinary") | just o | just l | just r with binOpFromJSON o | exprFromJSON l | exprFromJSON r
|
exprFromObject obj | just (string "AstExprBinary") | just o | just l | just r with binOpFromJSON o | exprFromJSON l | exprFromJSON r
|
||||||
exprFromObject obj | just (string "AstExprBinary") | just o | just l | just r | Right o′ | Right l′ | Right r′ = Right (binexp l′ o′ r′)
|
exprFromObject obj | just (string "AstExprBinary") | just o | just l | just r | Right o′ | Right l′ | Right r′ = Right (binexp l′ o′ r′)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
return true == false
|
|
@ -0,0 +1 @@
|
||||||
|
false
|
|
@ -0,0 +1 @@
|
||||||
|
return 1 == 1
|
|
@ -0,0 +1 @@
|
||||||
|
true
|
Loading…
Add table
Reference in a new issue