def test_call_missing_return_expression(): assert_error( """ function f() -> int; main { /*!*/ call f(); /*!*/ } """, Diagnostic.Messages.CALL_NO_RETURN_EXPRESSION, "f", "int")
def test_call_argument_wrong_type(): assert_error( """ function f(int[] a); main { call f(/*!*/ 0 /*!*/); } """, Diagnostic.Messages.CALL_WRONG_ARGS_TYPE, "a", "f", "int[]", "int")
def test_call_not_defined(): assert_error( """ function f(); main { /*!*/ call g(); /*!*/ } """, Diagnostic.Messages.FUNCTION_NOT_DECLARED, "g")
def test_call_extra_arguments(): assert_error( """ function f(); main { /*!*/ call f(0, 1); /*!*/ } """, Diagnostic.Messages.CALL_WRONG_ARGS_NUMBER, "f", 0, 2)
def test_call_missing_arguments(): assert_error( """ function f(int a, int b); main { /*!*/ call f(0); /*!*/ } """, Diagnostic.Messages.CALL_WRONG_ARGS_NUMBER, "f", 2, 1)
def test_call_return_expression_wrong_type(): assert_error( """ function f() -> int; main { var int[] a; call f() -> /*!*/ a /*!*/; } """, Diagnostic.Messages.CALL_WRONG_RETURN_EXPRESSION, "f", "int", "int[]")
def test_call_extra_return_expression(): assert_error( """ function f(); main { var int a; call f() -> /*!*/ a /*!*/; } """, Diagnostic.Messages.FUNCTION_DOES_NOT_RETURN_VALUE, "f")
def test_missing_local_flush(): assert_error( """ main { var int a; write 5; read a; } """, Diagnostic.Messages.MISSING_FLUSH)
def test_missing_flush_for_2(): assert_error( """ main { var int a; for (i : 5) { read a; write 4; } } """, Diagnostic.Messages.MISSING_FLUSH)
def test_missing_flush_init(): assert_error( """ init { write 4; } main { var int a; read a; } """, Diagnostic.Messages.MISSING_FLUSH)
def test_missing_flush_for_3(): assert_error( """ main { var int a, b; for (i : 5) { flush; read a; write 4; } read b; } """, Diagnostic.Messages.MISSING_FLUSH)
def test_missing_flush_if(): assert_error( """ main { var int a, b; read a; if (a) { flush; } else { write 4; } read b; } """, Diagnostic.Messages.MISSING_FLUSH)
def test_callback_accept_scalars(): assert_error( """ callback f(int a, /*!*/ int[] b /*!*/) {} main {} """, Diagnostic.Messages.CALLBACK_PARAMETERS_MUST_BE_SCALARS)
def test_function_returns_scalar(): assert_error( """ function f() -> /*!*/ int[] /*!*/ ; main {} """, Diagnostic.Messages.RETURN_TYPE_MUST_BE_SCALAR)
def test_callback_returns_scalar(): assert_error(""" callback f(int a) -> /*!*/ int[] /*!*/ {} main {} """, "return type must be a scalar")