git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #958 from purescript/js-op-precedence
08b38fdGary Burgess
examples/passing/OperatorAssociativity.purs+16
@@ -40,3 +40,19 @@ main = do
40
40
41 assert (4 % (9 / 3) == 1) "4 % (9 / 3) == 1"
41 assert (4 % (9 / 3) == 1) "4 % (9 / 3) == 1"
42 assert ((4 % 9) / 2 == 2) "(4 % 9) / 2 == 2"
42 assert ((4 % 9) / 2 == 2) "(4 % 9) / 2 == 2"
43+
44+ assert (not (1 < 0) == true) "not (1 < 0) == true"
45+ assert (not (complement (1 + 10) == 8) == true) "not (complement (1 + 10) == 8) == true"
46+ assert (not ((negate 1) < 0) == false) "not ((negate 1) < 0) == false"
47+
48+ assert (negate (1 + 10) == -11) "negate (1 + 10) == -11"
49+
50+ assert (2 * 3 / 4 == 1.5) "2 * 3 / 4 == 1.5"
51+ assert (1 * 2 * 3 * 4 * 5 / 6 == 20) "1 * 2 * 3 * 4 * 5 / 6 == 20"
52+ assert (complement (2 / 3 * 4) == -3) "complement (2 / 3 * 4) == -3"
53+
54+ assert (1 + 10 - 5 == 6) "1 + 10 - 5 == 6"
55+ assert (1 + 10 * 5 == 51) "1 + 10 * 5 == 51"
56+ assert (10 * 5 - 1 == 49) "10 * 5 - 1 == 49"
57+
58+ trace "Success!"
src/Language/PureScript/Pretty/JS.hs+14−14
@@ -272,26 +272,26 @@ prettyPrintJS' = A.runKleisli $ runPattern matchValue
272 ++ fromMaybe "" name
272 ++ fromMaybe "" name
273 ++ "(" ++ intercalate ", " args ++ ") "
273 ++ "(" ++ intercalate ", " args ++ ") "
274 ++ ret ]
274 ++ ret ]
275− , [ binary LessThan "<" ]
276− , [ binary LessThanOrEqualTo "<=" ]
277− , [ binary GreaterThan ">" ]
278− , [ binary GreaterThanOrEqualTo ">=" ]
279 , [ Wrap typeOf $ \_ s -> "typeof " ++ s ]
275 , [ Wrap typeOf $ \_ s -> "typeof " ++ s ]
280− , [ AssocR instanceOf $ \v1 v2 -> v1 ++ " instanceof " ++ v2 ]
281− , [ unary Not "!" ]
276+ , [ unary Not "!"
282− , [ unary BitwiseNot "~" ]
277+ , unary BitwiseNot "~"
283− , [ negateOperator ]
284− , [ unary Positive "+" ]
278+ , unary Positive "+"
279+ , negateOperator ]
285 , [ binary Multiply "*"
280 , [ binary Multiply "*"
286 , binary Divide "/"
281 , binary Divide "/"
287 , binary Modulus "%" ]
282 , binary Modulus "%" ]
288 , [ binary Add "+"
283 , [ binary Add "+"
289 , binary Subtract "-" ]
284 , binary Subtract "-" ]
290− , [ binary ShiftLeft "<<" ]
285+ , [ binary ShiftLeft "<<"
291− , [ binary ShiftRight ">>" ]
286+ , binary ShiftRight ">>"
292− , [ binary ZeroFillShiftRight ">>>" ]
287+ , binary ZeroFillShiftRight ">>>" ]
288+ , [ binary LessThan "<"
289+ , binary LessThanOrEqualTo "<="
290+ , binary GreaterThan ">"
291+ , binary GreaterThanOrEqualTo ">="
292+ , AssocR instanceOf $ \v1 v2 -> v1 ++ " instanceof " ++ v2 ]
293− , [ binary EqualTo "===" ]
293+ , [ binary EqualTo "==="
294− , [ binary NotEqualTo "!==" ]
294+ , binary NotEqualTo "!==" ]
295 , [ binary BitwiseAnd "&" ]
295 , [ binary BitwiseAnd "&" ]
296 , [ binary BitwiseXor "^" ]
296 , [ binary BitwiseXor "^" ]
297 , [ binary BitwiseOr "|" ]
297 , [ binary BitwiseOr "|" ]