aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unit-core/test-abort.c76
-rw-r--r--tests/unit-core/test-api-binary-operations-arithmetics.c28
-rw-r--r--tests/unit-core/test-api-binary-operations-comparisons.c85
-rw-r--r--tests/unit-core/test-api-binary-operations-instanceof.c18
-rw-r--r--tests/unit-core/test-api-errortype.c26
-rw-r--r--tests/unit-core/test-api-functiontype.c18
-rw-r--r--tests/unit-core/test-api-iteratortype.c18
-rw-r--r--tests/unit-core/test-api-object-property-names.c48
-rw-r--r--tests/unit-core/test-api-objecttype.c20
-rw-r--r--tests/unit-core/test-api-promise.c9
-rw-r--r--tests/unit-core/test-api-set-and-clear-error-flag.c1
-rw-r--r--tests/unit-core/test-api-strings.c29
-rw-r--r--tests/unit-core/test-api-value-type.c17
-rw-r--r--tests/unit-core/test-api.c240
-rw-r--r--tests/unit-core/test-arraybuffer.c71
-rw-r--r--tests/unit-core/test-backtrace.c22
-rw-r--r--tests/unit-core/test-bigint.c1
-rw-r--r--tests/unit-core/test-common.h79
-rw-r--r--tests/unit-core/test-container-operation.c15
-rw-r--r--tests/unit-core/test-container.c34
-rw-r--r--tests/unit-core/test-context-data.c37
-rw-r--r--tests/unit-core/test-dataview.c14
-rw-r--r--tests/unit-core/test-date-helpers.c16
-rw-r--r--tests/unit-core/test-error-callback.c4
-rw-r--r--tests/unit-core/test-from-property-descriptor.c3
-rw-r--r--tests/unit-core/test-get-own-property.c2
-rw-r--r--tests/unit-core/test-has-property.c3
-rw-r--r--tests/unit-core/test-internal-properties.c14
-rw-r--r--tests/unit-core/test-is-eval-code.c2
-rw-r--r--tests/unit-core/test-jmem.c2
-rw-r--r--tests/unit-core/test-json.c2
-rw-r--r--tests/unit-core/test-lit-char-helpers.c9
-rw-r--r--tests/unit-core/test-literal-storage.c1
-rw-r--r--tests/unit-core/test-mem-stats.c16
-rw-r--r--tests/unit-core/test-module-dynamic.c9
-rw-r--r--tests/unit-core/test-module-import-meta.c12
-rw-r--r--tests/unit-core/test-module.c42
-rw-r--r--tests/unit-core/test-native-callback-nested.c17
-rw-r--r--tests/unit-core/test-native-instanceof.c13
-rw-r--r--tests/unit-core/test-native-pointer.c23
-rw-r--r--tests/unit-core/test-newtarget.c29
-rw-r--r--tests/unit-core/test-number-converter.c6
-rw-r--r--tests/unit-core/test-number-to-int32.c14
-rw-r--r--tests/unit-core/test-number-to-string.c40
-rw-r--r--tests/unit-core/test-objects-foreach.c22
-rw-r--r--tests/unit-core/test-poolman.c5
-rw-r--r--tests/unit-core/test-promise-callback.c17
-rw-r--r--tests/unit-core/test-promise.c34
-rw-r--r--tests/unit-core/test-proxy.c17
-rw-r--r--tests/unit-core/test-realm.c4
-rw-r--r--tests/unit-core/test-regexp-dotall-unicode.c2
-rw-r--r--tests/unit-core/test-regression-3588.c30
-rw-r--r--tests/unit-core/test-resource-name.c32
-rw-r--r--tests/unit-core/test-script-user-value.c18
-rw-r--r--tests/unit-core/test-snapshot.c186
-rw-r--r--tests/unit-core/test-source-info.c18
-rw-r--r--tests/unit-core/test-string-to-number.c65
-rw-r--r--tests/unit-core/test-stringbuilder.c8
-rw-r--r--tests/unit-core/test-strings.c54
-rw-r--r--tests/unit-core/test-symbol.c78
-rw-r--r--tests/unit-core/test-to-integer.c17
-rw-r--r--tests/unit-core/test-to-length.c9
-rw-r--r--tests/unit-core/test-to-property-descriptor.c3
-rw-r--r--tests/unit-core/test-typedarray.c162
-rw-r--r--tests/unit-core/test-unicode.c5
-rw-r--r--tests/unit-core/test-vm-exec-stop.c16
-rw-r--r--tests/unit-core/test-vm-throw.c14
-rw-r--r--tests/unit-ext/module/jerry-module-test.c120
-rw-r--r--tests/unit-ext/module/my-broken-module.c1
-rw-r--r--tests/unit-ext/module/my-custom-module.c1
-rw-r--r--tests/unit-ext/test-common.h24
-rw-r--r--tests/unit-ext/test-ext-arg.c279
-rw-r--r--tests/unit-ext/test-ext-autorelease.c4
-rw-r--r--tests/unit-ext/test-ext-handle-scope-escape.c4
-rw-r--r--tests/unit-ext/test-ext-handle-scope-handle-prelist-escape.c8
-rw-r--r--tests/unit-ext/test-ext-handle-scope-handle-prelist.c8
-rw-r--r--tests/unit-ext/test-ext-handle-scope-nested.c4
-rw-r--r--tests/unit-ext/test-ext-handle-scope-remove.c4
-rw-r--r--tests/unit-ext/test-ext-handle-scope-root.c4
-rw-r--r--tests/unit-ext/test-ext-handle-scope.c4
-rw-r--r--tests/unit-ext/test-ext-method-register.c34
-rw-r--r--tests/unit-ext/test-ext-module-canonical.c12
-rw-r--r--tests/unit-ext/test-ext-module-empty.c3
-rw-r--r--tests/unit-math/test-math.c9
84 files changed, 1022 insertions, 1502 deletions
diff --git a/tests/unit-core/test-abort.c b/tests/unit-core/test-abort.c
index 6105feec..6d50b213 100644
--- a/tests/unit-core/test-abort.c
+++ b/tests/unit-core/test-abort.c
@@ -13,15 +13,13 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+#include "config.h"
#include "test-common.h"
static jerry_value_t
-callback_func (const jerry_call_info_t *call_info_p,
- const jerry_value_t args_p[],
- const jerry_length_t args_count)
+callback_func (const jerry_call_info_t *call_info_p, const jerry_value_t args_p[], const jerry_length_t args_count)
{
JERRY_UNUSED (call_info_p);
JERRY_UNUSED (args_p);
@@ -50,21 +48,17 @@ main (void)
jerry_release_value (callback_name);
jerry_release_value (global);
- const jerry_char_t inf_loop_code_src1[] = TEST_STRING_LITERAL (
- "while(true) {\n"
- " with ({}) {\n"
- " try {\n"
- " callback();\n"
- " } catch (e) {\n"
- " } finally {\n"
- " }\n"
- " }\n"
- "}"
- );
-
- jerry_value_t parsed_code_val = jerry_parse (inf_loop_code_src1,
- sizeof (inf_loop_code_src1) - 1,
- NULL);
+ const jerry_char_t inf_loop_code_src1[] = TEST_STRING_LITERAL ("while(true) {\n"
+ " with ({}) {\n"
+ " try {\n"
+ " callback();\n"
+ " } catch (e) {\n"
+ " } finally {\n"
+ " }\n"
+ " }\n"
+ "}");
+
+ jerry_value_t parsed_code_val = jerry_parse (inf_loop_code_src1, sizeof (inf_loop_code_src1) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
res = jerry_run (parsed_code_val);
@@ -74,30 +68,26 @@ main (void)
jerry_release_value (res);
jerry_release_value (parsed_code_val);
- const jerry_char_t inf_loop_code_src2[] = TEST_STRING_LITERAL (
- "function f() {"
- " while(true) {\n"
- " with ({}) {\n"
- " try {\n"
- " callback();\n"
- " } catch (e) {\n"
- " } finally {\n"
- " }\n"
- " }\n"
- " }"
- "}\n"
- "function g() {\n"
- " for (a in { x:5 })\n"
- " f();\n"
- "}\n"
- "\n"
- "with({})\n"
- " f();\n"
- );
-
- parsed_code_val = jerry_parse (inf_loop_code_src2,
- sizeof (inf_loop_code_src2) - 1,
- NULL);
+ const jerry_char_t inf_loop_code_src2[] = TEST_STRING_LITERAL ("function f() {"
+ " while(true) {\n"
+ " with ({}) {\n"
+ " try {\n"
+ " callback();\n"
+ " } catch (e) {\n"
+ " } finally {\n"
+ " }\n"
+ " }\n"
+ " }"
+ "}\n"
+ "function g() {\n"
+ " for (a in { x:5 })\n"
+ " f();\n"
+ "}\n"
+ "\n"
+ "with({})\n"
+ " f();\n");
+
+ parsed_code_val = jerry_parse (inf_loop_code_src2, sizeof (inf_loop_code_src2) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
res = jerry_run (parsed_code_val);
diff --git a/tests/unit-core/test-api-binary-operations-arithmetics.c b/tests/unit-core/test-api-binary-operations-arithmetics.c
index a41206ec..cd695aaa 100644
--- a/tests/unit-core/test-api-binary-operations-arithmetics.c
+++ b/tests/unit-core/test-api-binary-operations-arithmetics.c
@@ -18,19 +18,20 @@
#include "test-common.h"
#define T(op, lhs, rhs, res) \
- { op, lhs, rhs, res }
+ { \
+ op, lhs, rhs, res \
+ }
#define T_NAN(op, lhs, rhs) \
- { op, lhs, rhs }
+ { \
+ op, lhs, rhs \
+ }
-#define T_ERR(op, lsh, rhs) \
- T_NAN (op, lsh, rhs)
+#define T_ERR(op, lsh, rhs) T_NAN (op, lsh, rhs)
-#define T_ARI(lhs, rhs) \
- T_NAN (JERRY_BIN_OP_SUB, lhs, rhs), \
- T_NAN (JERRY_BIN_OP_MUL, lhs, rhs), \
- T_NAN (JERRY_BIN_OP_DIV, lhs, rhs), \
- T_NAN (JERRY_BIN_OP_REM, lhs, rhs)
+#define T_ARI(lhs, rhs) \
+ T_NAN (JERRY_BIN_OP_SUB, lhs, rhs), T_NAN (JERRY_BIN_OP_MUL, lhs, rhs), T_NAN (JERRY_BIN_OP_DIV, lhs, rhs), \
+ T_NAN (JERRY_BIN_OP_REM, lhs, rhs)
typedef struct
{
@@ -60,8 +61,7 @@ main (void)
jerry_value_t obj2 = jerry_eval ((const jerry_char_t *) "o={x:1};o", 9, JERRY_PARSE_NO_OPTS);
jerry_value_t err1 = jerry_create_error (JERRY_ERROR_SYNTAX, (const jerry_char_t *) "error");
- test_nan_entry_t test_nans[] =
- {
+ test_nan_entry_t test_nans[] = {
/* Testing addition (+) */
T_NAN (JERRY_BIN_OP_ADD, jerry_create_number (3.1), jerry_create_undefined ()),
T_NAN (JERRY_BIN_OP_ADD, jerry_create_undefined (), jerry_create_undefined ()),
@@ -115,8 +115,7 @@ main (void)
jerry_release_value (result);
}
- test_entry_t tests[] =
- {
+ test_entry_t tests[] = {
/* Testing addition (+) */
T (JERRY_BIN_OP_ADD, jerry_create_number (5.0), jerry_create_number (5.0), jerry_create_number (10.0)),
T (JERRY_BIN_OP_ADD, jerry_create_number (3.1), jerry_create_number (10), jerry_create_number (13.1)),
@@ -241,8 +240,7 @@ main (void)
jerry_value_t obj3 = jerry_eval ((const jerry_char_t *) "o={valueOf:function(){throw 5}};o", 33, JERRY_PARSE_NO_OPTS);
- test_error_entry_t error_tests[] =
- {
+ test_error_entry_t error_tests[] = {
/* Testing addition (+) */
T_ERR (JERRY_BIN_OP_ADD, jerry_acquire_value (err1), jerry_acquire_value (err1)),
T_ERR (JERRY_BIN_OP_ADD, jerry_acquire_value (err1), jerry_create_undefined ()),
diff --git a/tests/unit-core/test-api-binary-operations-comparisons.c b/tests/unit-core/test-api-binary-operations-comparisons.c
index 50881e19..0a2698c1 100644
--- a/tests/unit-core/test-api-binary-operations-comparisons.c
+++ b/tests/unit-core/test-api-binary-operations-comparisons.c
@@ -18,7 +18,9 @@
#include "test-common.h"
#define T(op, lhs, rhs, res) \
- { op, lhs, rhs, res }
+ { \
+ op, lhs, rhs, res \
+ }
typedef struct
{
@@ -39,8 +41,7 @@ main (void)
jerry_value_t obj2 = jerry_eval ((const jerry_char_t *) "o={x:1};o", 9, JERRY_PARSE_NO_OPTS);
jerry_value_t err1 = jerry_create_error (JERRY_ERROR_SYNTAX, (const jerry_char_t *) "error");
- test_entry_t tests[] =
- {
+ test_entry_t tests[] = {
/* Testing strict equal comparison */
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_number (5.0), jerry_create_number (5.0), true),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_number (3.1), jerry_create_number (10), false),
@@ -95,10 +96,7 @@ main (void)
jerry_create_string ((const jerry_char_t *) "example string"),
jerry_create_undefined (),
false),
- T (JERRY_BIN_OP_EQUAL,
- jerry_create_string ((const jerry_char_t *) "example string"),
- jerry_create_null (),
- false),
+ T (JERRY_BIN_OP_EQUAL, jerry_create_string ((const jerry_char_t *) "example string"), jerry_create_null (), false),
T (JERRY_BIN_OP_EQUAL,
jerry_create_string ((const jerry_char_t *) "example string"),
jerry_create_number (5.0),
@@ -132,18 +130,9 @@ main (void)
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_string ((const jerry_char_t *) "2"),
true),
- T (JERRY_BIN_OP_LESS,
- jerry_create_string ((const jerry_char_t *) "1"),
- jerry_create_undefined (),
- false),
- T (JERRY_BIN_OP_LESS,
- jerry_create_string ((const jerry_char_t *) "1"),
- jerry_create_null (),
- false),
- T (JERRY_BIN_OP_LESS,
- jerry_create_string ((const jerry_char_t *) "1"),
- jerry_create_number (5.0),
- true),
+ T (JERRY_BIN_OP_LESS, jerry_create_string ((const jerry_char_t *) "1"), jerry_create_undefined (), false),
+ T (JERRY_BIN_OP_LESS, jerry_create_string ((const jerry_char_t *) "1"), jerry_create_null (), false),
+ T (JERRY_BIN_OP_LESS, jerry_create_string ((const jerry_char_t *) "1"), jerry_create_number (5.0), true),
T (JERRY_BIN_OP_LESS, jerry_create_undefined (), jerry_create_undefined (), false),
T (JERRY_BIN_OP_LESS, jerry_create_undefined (), jerry_create_null (), false),
T (JERRY_BIN_OP_LESS, jerry_create_null (), jerry_create_null (), false),
@@ -166,22 +155,10 @@ main (void)
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_string ((const jerry_char_t *) "1"),
true),
- T (JERRY_BIN_OP_LESS_EQUAL,
- jerry_create_string ((const jerry_char_t *) "1"),
- jerry_create_undefined (),
- false),
- T (JERRY_BIN_OP_LESS_EQUAL,
- jerry_create_string ((const jerry_char_t *) "1"),
- jerry_create_null (),
- false),
- T (JERRY_BIN_OP_LESS_EQUAL,
- jerry_create_string ((const jerry_char_t *) "1"),
- jerry_create_number (5.0),
- true),
- T (JERRY_BIN_OP_LESS_EQUAL,
- jerry_create_string ((const jerry_char_t *) "5.0"),
- jerry_create_number (5.0),
- true),
+ T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_string ((const jerry_char_t *) "1"), jerry_create_undefined (), false),
+ T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_string ((const jerry_char_t *) "1"), jerry_create_null (), false),
+ T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_string ((const jerry_char_t *) "1"), jerry_create_number (5.0), true),
+ T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_string ((const jerry_char_t *) "5.0"), jerry_create_number (5.0), true),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_undefined (), jerry_create_undefined (), false),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_undefined (), jerry_create_null (), false),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_null (), jerry_create_null (), true),
@@ -203,18 +180,9 @@ main (void)
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_string ((const jerry_char_t *) "2"),
false),
- T (JERRY_BIN_OP_GREATER,
- jerry_create_string ((const jerry_char_t *) "1"),
- jerry_create_undefined (),
- false),
- T (JERRY_BIN_OP_GREATER,
- jerry_create_string ((const jerry_char_t *) "1"),
- jerry_create_null (),
- true),
- T (JERRY_BIN_OP_GREATER,
- jerry_create_number (5.0),
- jerry_create_string ((const jerry_char_t *) "1"),
- true),
+ T (JERRY_BIN_OP_GREATER, jerry_create_string ((const jerry_char_t *) "1"), jerry_create_undefined (), false),
+ T (JERRY_BIN_OP_GREATER, jerry_create_string ((const jerry_char_t *) "1"), jerry_create_null (), true),
+ T (JERRY_BIN_OP_GREATER, jerry_create_number (5.0), jerry_create_string ((const jerry_char_t *) "1"), true),
T (JERRY_BIN_OP_GREATER, jerry_create_undefined (), jerry_create_undefined (), false),
T (JERRY_BIN_OP_GREATER, jerry_create_undefined (), jerry_create_null (), false),
T (JERRY_BIN_OP_GREATER, jerry_create_null (), jerry_create_null (), false),
@@ -237,22 +205,10 @@ main (void)
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_string ((const jerry_char_t *) "1"),
true),
- T (JERRY_BIN_OP_GREATER_EQUAL,
- jerry_create_string ((const jerry_char_t *) "1"),
- jerry_create_undefined (),
- false),
- T (JERRY_BIN_OP_GREATER_EQUAL,
- jerry_create_string ((const jerry_char_t *) "1"),
- jerry_create_null (),
- true),
- T (JERRY_BIN_OP_GREATER_EQUAL,
- jerry_create_number (5.0),
- jerry_create_string ((const jerry_char_t *) "1"),
- true),
- T (JERRY_BIN_OP_GREATER_EQUAL,
- jerry_create_string ((const jerry_char_t *) "5.0"),
- jerry_create_number (5.0),
- true),
+ T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_string ((const jerry_char_t *) "1"), jerry_create_undefined (), false),
+ T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_string ((const jerry_char_t *) "1"), jerry_create_null (), true),
+ T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_number (5.0), jerry_create_string ((const jerry_char_t *) "1"), true),
+ T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_string ((const jerry_char_t *) "5.0"), jerry_create_number (5.0), true),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_undefined (), jerry_create_undefined (), false),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_undefined (), jerry_create_null (), false),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_null (), jerry_create_null (), true),
@@ -272,8 +228,7 @@ main (void)
jerry_release_value (result);
}
- test_entry_t error_tests[] =
- {
+ test_entry_t error_tests[] = {
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (err1), jerry_acquire_value (err1), true),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (err1), jerry_create_undefined (), true),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_undefined (), jerry_acquire_value (err1), true),
diff --git a/tests/unit-core/test-api-binary-operations-instanceof.c b/tests/unit-core/test-api-binary-operations-instanceof.c
index 7765484e..5c268cfa 100644
--- a/tests/unit-core/test-api-binary-operations-instanceof.c
+++ b/tests/unit-core/test-api-binary-operations-instanceof.c
@@ -18,7 +18,9 @@
#include "test-common.h"
#define T(lhs, rhs, res) \
- { lhs, rhs, res }
+ { \
+ lhs, rhs, res \
+ }
typedef struct
{
@@ -60,8 +62,7 @@ main (void)
jerry_value_t error = jerry_create_error_from_value (base_obj, false);
- test_entry_t bool_tests[] =
- {
+ test_entry_t bool_tests[] = {
T (jerry_acquire_value (instance_val), jerry_acquire_value (constructor), true),
T (jerry_acquire_value (no_proto_instance_val), jerry_acquire_value (constructor), false),
T (jerry_acquire_value (base_obj), jerry_acquire_value (constructor), false)
@@ -69,9 +70,7 @@ main (void)
for (uint32_t idx = 0; idx < sizeof (bool_tests) / sizeof (test_entry_t); idx++)
{
- jerry_value_t result = jerry_binary_operation (JERRY_BIN_OP_INSTANCEOF,
- bool_tests[idx].lhs,
- bool_tests[idx].rhs);
+ jerry_value_t result = jerry_binary_operation (JERRY_BIN_OP_INSTANCEOF, bool_tests[idx].lhs, bool_tests[idx].rhs);
TEST_ASSERT (!jerry_value_is_error (result));
TEST_ASSERT (jerry_value_is_true (result) == bool_tests[idx].expected);
jerry_release_value (bool_tests[idx].lhs);
@@ -79,8 +78,7 @@ main (void)
jerry_release_value (result);
}
- test_entry_t error_tests[] =
- {
+ test_entry_t error_tests[] = {
T (jerry_acquire_value (constructor), jerry_acquire_value (instance_val), true),
T (jerry_create_undefined (), jerry_acquire_value (constructor), true),
T (jerry_acquire_value (instance_val), jerry_create_undefined (), true),
@@ -99,9 +97,7 @@ main (void)
for (uint32_t idx = 0; idx < sizeof (error_tests) / sizeof (test_entry_t); idx++)
{
- jerry_value_t result = jerry_binary_operation (JERRY_BIN_OP_INSTANCEOF,
- error_tests[idx].lhs,
- error_tests[idx].rhs);
+ jerry_value_t result = jerry_binary_operation (JERRY_BIN_OP_INSTANCEOF, error_tests[idx].lhs, error_tests[idx].rhs);
TEST_ASSERT (jerry_value_is_error (result) == error_tests[idx].expected);
jerry_release_value (error_tests[idx].lhs);
jerry_release_value (error_tests[idx].rhs);
diff --git a/tests/unit-core/test-api-errortype.c b/tests/unit-core/test-api-errortype.c
index 2e0d9700..645f1806 100644
--- a/tests/unit-core/test-api-errortype.c
+++ b/tests/unit-core/test-api-errortype.c
@@ -14,6 +14,7 @@
*/
#include "jerryscript.h"
+
#include "test-common.h"
int
@@ -23,20 +24,12 @@ main (void)
jerry_init (JERRY_INIT_EMPTY);
- jerry_error_t errors[] =
- {
- JERRY_ERROR_COMMON,
- JERRY_ERROR_EVAL,
- JERRY_ERROR_RANGE,
- JERRY_ERROR_REFERENCE,
- JERRY_ERROR_SYNTAX,
- JERRY_ERROR_TYPE,
- JERRY_ERROR_URI
- };
+ jerry_error_t errors[] = { JERRY_ERROR_COMMON, JERRY_ERROR_EVAL, JERRY_ERROR_RANGE, JERRY_ERROR_REFERENCE,
+ JERRY_ERROR_SYNTAX, JERRY_ERROR_TYPE, JERRY_ERROR_URI };
for (size_t idx = 0; idx < sizeof (errors) / sizeof (errors[0]); idx++)
{
- jerry_value_t error_obj = jerry_create_error (errors[idx], (const jerry_char_t *)"test");
+ jerry_value_t error_obj = jerry_create_error (errors[idx], (const jerry_char_t *) "test");
TEST_ASSERT (jerry_value_is_error (error_obj));
TEST_ASSERT (jerry_get_error_type (error_obj) == errors[idx]);
@@ -47,8 +40,7 @@ main (void)
jerry_release_value (error_obj);
}
- jerry_value_t test_values[] =
- {
+ jerry_value_t test_values[] = {
jerry_create_number (11),
jerry_create_string ((const jerry_char_t *) "message"),
jerry_create_boolean (true),
@@ -64,18 +56,14 @@ main (void)
char test_source[] = "\xF0\x9D\x84\x9E";
- jerry_value_t result = jerry_parse ((const jerry_char_t *) test_source,
- sizeof (test_source) - 1,
- NULL);
+ jerry_value_t result = jerry_parse ((const jerry_char_t *) test_source, sizeof (test_source) - 1, NULL);
TEST_ASSERT (jerry_value_is_error (result));
TEST_ASSERT (jerry_get_error_type (result) == JERRY_ERROR_SYNTAX);
jerry_release_value (result);
char test_invalid_error[] = "Object.create(Error.prototype)";
- result = jerry_eval ((const jerry_char_t *) test_invalid_error,
- sizeof (test_invalid_error) - 1,
- JERRY_PARSE_NO_OPTS);
+ result = jerry_eval ((const jerry_char_t *) test_invalid_error, sizeof (test_invalid_error) - 1, JERRY_PARSE_NO_OPTS);
TEST_ASSERT (!jerry_value_is_error (result) && jerry_value_is_object (result));
TEST_ASSERT (jerry_get_error_type (result) == JERRY_ERROR_NONE);
diff --git a/tests/unit-core/test-api-functiontype.c b/tests/unit-core/test-api-functiontype.c
index c3c05954..0437a566 100644
--- a/tests/unit-core/test-api-functiontype.c
+++ b/tests/unit-core/test-api-functiontype.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
typedef struct
@@ -26,8 +27,14 @@ typedef struct
bool is_async;
} test_entry_t;
-#define ENTRY(TYPE, VALUE) { TYPE, VALUE, true, false }
-#define ENTRY_IF(TYPE, VALUE, FEATURE, ASYNC) { TYPE, VALUE, jerry_is_feature_enabled (FEATURE), ASYNC }
+#define ENTRY(TYPE, VALUE) \
+ { \
+ TYPE, VALUE, true, false \
+ }
+#define ENTRY_IF(TYPE, VALUE, FEATURE, ASYNC) \
+ { \
+ TYPE, VALUE, jerry_is_feature_enabled (FEATURE), ASYNC \
+ }
#define EVALUATE(BUFF) (jerry_eval ((BUFF), sizeof ((BUFF)) - 1, JERRY_PARSE_NO_OPTS))
static jerry_value_t
test_ext_function (const jerry_call_info_t *call_info_p, /**< call information */
@@ -59,8 +66,7 @@ main (void)
const jerry_char_t simple_function[] = "function f() {}; f";
const jerry_char_t bound_function[] = "function f() {}; f.bind(1,2)";
- test_entry_t entries[] =
- {
+ test_entry_t entries[] = {
ENTRY (JERRY_FUNCTION_TYPE_NONE, jerry_create_number (-33.0)),
ENTRY (JERRY_FUNCTION_TYPE_NONE, jerry_create_boolean (true)),
ENTRY (JERRY_FUNCTION_TYPE_NONE, jerry_create_undefined ()),
diff --git a/tests/unit-core/test-api-iteratortype.c b/tests/unit-core/test-api-iteratortype.c
index e7ec98a2..7f0d9a40 100644
--- a/tests/unit-core/test-api-iteratortype.c
+++ b/tests/unit-core/test-api-iteratortype.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
typedef struct
@@ -25,8 +26,14 @@ typedef struct
bool active;
} test_entry_t;
-#define ENTRY(TYPE, VALUE) { TYPE, VALUE, true }
-#define ENTRY_IF(TYPE, VALUE, FEATURE) { TYPE, VALUE, jerry_is_feature_enabled (FEATURE) }
+#define ENTRY(TYPE, VALUE) \
+ { \
+ TYPE, VALUE, true \
+ }
+#define ENTRY_IF(TYPE, VALUE, FEATURE) \
+ { \
+ TYPE, VALUE, jerry_is_feature_enabled (FEATURE) \
+ }
#define EVALUATE(BUFF) (jerry_eval ((BUFF), sizeof ((BUFF)) - 1, JERRY_PARSE_NO_OPTS))
int
@@ -58,8 +65,7 @@ main (void)
const jerry_char_t set_iterator_entries[] = "new Set([1, 2, 3]).entries()";
const jerry_char_t set_iterator_symbol_iterator[] = "new Set([1, 2, 3])[Symbol.iterator]()";
- test_entry_t entries[] =
- {
+ test_entry_t entries[] = {
ENTRY (JERRY_ITERATOR_TYPE_NONE, jerry_create_number (-33.0)),
ENTRY (JERRY_ITERATOR_TYPE_NONE, jerry_create_boolean (true)),
ENTRY (JERRY_ITERATOR_TYPE_NONE, jerry_create_undefined ()),
diff --git a/tests/unit-core/test-api-object-property-names.c b/tests/unit-core/test-api-object-property-names.c
index 0f9a98f3..9934801f 100644
--- a/tests/unit-core/test-api-object-property-names.c
+++ b/tests/unit-core/test-api-object-property-names.c
@@ -13,25 +13,18 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
-static const char *prop_names[] =
-{
- "val1",
- "val2",
- "val3",
- "val4",
- "val5",
- "37",
- "symbol"
-};
+static const char *prop_names[] = { "val1", "val2", "val3", "val4", "val5", "37", "symbol" };
static jerry_char_t buffer[256] = { 0 };
-static void create_and_set_property (const jerry_value_t object, const char *prop_name)
+static void
+create_and_set_property (const jerry_value_t object, const char *prop_name)
{
jerry_value_t jprop_name = jerry_create_string ((const jerry_char_t *) prop_name);
jerry_value_t ret_val = jerry_set_property (object, jprop_name, jerry_create_undefined ());
@@ -40,7 +33,8 @@ static void create_and_set_property (const jerry_value_t object, const char *pro
jerry_release_value (ret_val);
} /* create_and_set_property */
-static void compare_prop_name (const jerry_value_t object, const char *prop_name, uint32_t idx)
+static void
+compare_prop_name (const jerry_value_t object, const char *prop_name, uint32_t idx)
{
jerry_value_t name = jerry_get_property_by_index (object, idx);
TEST_ASSERT (jerry_value_is_string (name) || jerry_value_is_number (name));
@@ -61,10 +55,11 @@ static void compare_prop_name (const jerry_value_t object, const char *prop_name
jerry_release_value (name);
} /* compare_prop_name */
-static void define_property (const jerry_value_t object,
- const char *prop_name,
- jerry_property_descriptor_t *prop_desc_p,
- bool is_symbol)
+static void
+define_property (const jerry_value_t object,
+ const char *prop_name,
+ jerry_property_descriptor_t *prop_desc_p,
+ bool is_symbol)
{
jerry_value_t jname = jerry_create_string ((const jerry_char_t *) prop_name);
jerry_value_t ret_val;
@@ -105,11 +100,8 @@ main (void)
jerry_value_t names;
jerry_property_descriptor_t prop_desc = jerry_property_descriptor_create ();
- prop_desc.flags |= (JERRY_PROP_IS_CONFIGURABLE_DEFINED
- | JERRY_PROP_IS_CONFIGURABLE
- | JERRY_PROP_IS_WRITABLE_DEFINED
- | JERRY_PROP_IS_WRITABLE
- | JERRY_PROP_IS_ENUMERABLE_DEFINED);
+ prop_desc.flags |= (JERRY_PROP_IS_CONFIGURABLE_DEFINED | JERRY_PROP_IS_CONFIGURABLE | JERRY_PROP_IS_WRITABLE_DEFINED
+ | JERRY_PROP_IS_WRITABLE | JERRY_PROP_IS_ENUMERABLE_DEFINED);
// Test enumerable - non-enumerable filter
define_property (test_object, prop_names[2], &prop_desc, false);
@@ -163,9 +155,9 @@ main (void)
// Test number and string index exclusion
define_property (test_object, prop_names[5], &prop_desc, false);
- names = jerry_object_get_property_names (test_object, JERRY_PROPERTY_FILTER_ALL
- | JERRY_PROPERTY_FILTER_EXCLUDE_STRINGS
- | JERRY_PROPERTY_FILTER_INTEGER_INDICES_AS_NUMBER);
+ names = jerry_object_get_property_names (test_object,
+ JERRY_PROPERTY_FILTER_ALL | JERRY_PROPERTY_FILTER_EXCLUDE_STRINGS
+ | JERRY_PROPERTY_FILTER_INTEGER_INDICES_AS_NUMBER);
TEST_ASSERT (jerry_get_array_length (names) == (uint32_t) 1);
compare_prop_name (names, prop_names[5], 0);
jerry_release_value (names);
@@ -185,8 +177,8 @@ main (void)
// Test symbol exclusion
define_property (test_object, prop_names[6], &prop_desc, true);
- names = jerry_object_get_property_names (test_object,
- JERRY_PROPERTY_FILTER_ALL | JERRY_PROPERTY_FILTER_EXCLUDE_SYMBOLS);
+ names =
+ jerry_object_get_property_names (test_object, JERRY_PROPERTY_FILTER_ALL | JERRY_PROPERTY_FILTER_EXCLUDE_SYMBOLS);
TEST_ASSERT (jerry_get_array_length (names) == (uint32_t) 6);
jerry_release_value (names);
names = jerry_object_get_property_names (test_object, JERRY_PROPERTY_FILTER_ALL);
diff --git a/tests/unit-core/test-api-objecttype.c b/tests/unit-core/test-api-objecttype.c
index 9ee4bfef..abd66f58 100644
--- a/tests/unit-core/test-api-objecttype.c
+++ b/tests/unit-core/test-api-objecttype.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
typedef struct
@@ -25,10 +26,16 @@ typedef struct
bool active;
} test_entry_t;
-#define ENTRY(TYPE, VALUE) { TYPE, VALUE, true }
-#define ENTRY_IF(TYPE, VALUE, FEATURE) { TYPE, VALUE, jerry_is_feature_enabled (FEATURE) }
+#define ENTRY(TYPE, VALUE) \
+ { \
+ TYPE, VALUE, true \
+ }
+#define ENTRY_IF(TYPE, VALUE, FEATURE) \
+ { \
+ TYPE, VALUE, jerry_is_feature_enabled (FEATURE) \
+ }
#define EVALUATE(BUFF) (jerry_eval ((BUFF), sizeof ((BUFF)) - 1, JERRY_PARSE_NO_OPTS))
-#define PARSE(OPTS) (jerry_parse ((const jerry_char_t *) "", 0, (OPTS)))
+#define PARSE(OPTS) (jerry_parse ((const jerry_char_t *) "", 0, (OPTS)))
static jerry_value_t
test_ext_function (const jerry_call_info_t *call_info_p, /**< call information */
const jerry_value_t args_p[], /**< array of arguments */
@@ -101,8 +108,7 @@ main (void)
jerry_parse_options_t module_parse_options;
module_parse_options.options = JERRY_PARSE_MODULE;
- test_entry_t entries[] =
- {
+ test_entry_t entries[] = {
ENTRY (JERRY_OBJECT_TYPE_NONE, jerry_create_number (-33.0)),
ENTRY (JERRY_OBJECT_TYPE_NONE, jerry_create_boolean (true)),
ENTRY (JERRY_OBJECT_TYPE_NONE, jerry_create_undefined ()),
diff --git a/tests/unit-core/test-api-promise.c b/tests/unit-core/test-api-promise.c
index c2ced24d..94e5e6ee 100644
--- a/tests/unit-core/test-api-promise.c
+++ b/tests/unit-core/test-api-promise.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
static void
@@ -157,9 +158,7 @@ test_promise_from_js (void)
{
const jerry_char_t test_source[] = "(new Promise(function(rs, rj) { rs(30); })).then(function(v) { return v + 1; })";
- jerry_value_t parsed_code_val = jerry_parse (test_source,
- sizeof (test_source) - 1,
- NULL);
+ jerry_value_t parsed_code_val = jerry_parse (test_source, sizeof (test_source) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
jerry_value_t res = jerry_run (parsed_code_val);
diff --git a/tests/unit-core/test-api-set-and-clear-error-flag.c b/tests/unit-core/test-api-set-and-clear-error-flag.c
index 3ac27722..eba6b897 100644
--- a/tests/unit-core/test-api-set-and-clear-error-flag.c
+++ b/tests/unit-core/test-api-set-and-clear-error-flag.c
@@ -14,6 +14,7 @@
*/
#include "jerryscript.h"
+
#include "test-common.h"
static void
diff --git a/tests/unit-core/test-api-strings.c b/tests/unit-core/test-api-strings.c
index 00419871..a3b2496a 100644
--- a/tests/unit-core/test-api-strings.c
+++ b/tests/unit-core/test-api-strings.c
@@ -24,7 +24,7 @@ strict_equals (jerry_value_t a, /**< the first string to compare */
const jerry_char_t is_equal_src[] = "var isEqual = function(a, b) { return (a === b); }; isEqual";
jerry_value_t is_equal_fn_val = jerry_eval (is_equal_src, sizeof (is_equal_src) - 1, JERRY_PARSE_NO_OPTS);
TEST_ASSERT (!jerry_value_is_error (is_equal_fn_val));
- jerry_value_t args[2] = {a, b};
+ jerry_value_t args[2] = { a, b };
jerry_value_t res = jerry_call_function (is_equal_fn_val, jerry_create_undefined (), args, 2);
TEST_ASSERT (!jerry_value_is_error (res));
TEST_ASSERT (jerry_value_is_boolean (res));
@@ -102,7 +102,7 @@ main (void)
utf8_length = jerry_get_utf8_string_length (args[0]);
cesu8_sz = jerry_get_string_size (args[0]);
- utf8_sz = jerry_get_utf8_string_size (args[0]);
+ utf8_sz = jerry_get_utf8_string_size (args[0]);
TEST_ASSERT (cesu8_length == 10 && utf8_length == 8);
TEST_ASSERT (cesu8_sz != utf8_sz);
@@ -157,7 +157,7 @@ main (void)
utf8_length = jerry_get_utf8_string_length (args[0]);
cesu8_sz = jerry_get_string_size (args[0]);
- utf8_sz = jerry_get_utf8_string_size (args[0]);
+ utf8_sz = jerry_get_utf8_string_size (args[0]);
TEST_ASSERT (cesu8_length == 7 && utf8_length == 6);
TEST_ASSERT (cesu8_sz != utf8_sz);
@@ -172,7 +172,7 @@ main (void)
utf8_length = jerry_get_utf8_string_length (args[0]);
cesu8_sz = jerry_get_string_size (args[0]);
- utf8_sz = jerry_get_utf8_string_size (args[0]);
+ utf8_sz = jerry_get_utf8_string_size (args[0]);
TEST_ASSERT (cesu8_length == utf8_length);
TEST_ASSERT (cesu8_length == 10);
@@ -184,20 +184,14 @@ main (void)
{
jerry_value_t test_str = jerry_create_string ((const jerry_char_t *) "3");
char result_string[1] = { 'E' };
- jerry_size_t copied_utf8 = jerry_substring_to_utf8_char_buffer (test_str,
- 0,
- 1,
- (jerry_char_t *) result_string,
- sizeof (result_string));
+ jerry_size_t copied_utf8 =
+ jerry_substring_to_utf8_char_buffer (test_str, 0, 1, (jerry_char_t *) result_string, sizeof (result_string));
TEST_ASSERT (copied_utf8 == 1);
TEST_ASSERT (result_string[0] == '3');
result_string[0] = 'E';
- jerry_size_t copied = jerry_substring_to_char_buffer (test_str,
- 0,
- 1,
- (jerry_char_t *) result_string,
- sizeof (result_string));
+ jerry_size_t copied =
+ jerry_substring_to_char_buffer (test_str, 0, 1, (jerry_char_t *) result_string, sizeof (result_string));
TEST_ASSERT (copied == 1);
TEST_ASSERT (result_string[0] == '3');
@@ -276,11 +270,8 @@ main (void)
TEST_ASSERT (sz == 8);
TEST_ASSERT (!strncmp (supl_substring, "\x73\x74\x72\x3a \xed\xa0\x80", sz));
- sz = jerry_substring_to_char_buffer (args[0],
- cesu8_length - 1,
- cesu8_length,
- (jerry_char_t *) supl_substring,
- cesu8_sz);
+ sz =
+ jerry_substring_to_char_buffer (args[0], cesu8_length - 1, cesu8_length, (jerry_char_t *) supl_substring, cesu8_sz);
TEST_ASSERT (sz == 3);
TEST_ASSERT (!strncmp (supl_substring, "\xed\xb6\x8a", sz));
diff --git a/tests/unit-core/test-api-value-type.c b/tests/unit-core/test-api-value-type.c
index 1dce4274..208cc888 100644
--- a/tests/unit-core/test-api-value-type.c
+++ b/tests/unit-core/test-api-value-type.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
typedef struct
@@ -24,7 +25,10 @@ typedef struct
jerry_value_t value;
} test_entry_t;
-#define ENTRY(TYPE, VALUE) { TYPE, VALUE }
+#define ENTRY(TYPE, VALUE) \
+ { \
+ TYPE, VALUE \
+ }
static jerry_value_t
test_ext_function (const jerry_call_info_t *call_info_p, /**< call information */
@@ -46,8 +50,7 @@ main (void)
const jerry_char_t test_eval_function[] = "function demo(a) { return a + 1; }; demo";
- test_entry_t entries[] =
- {
+ test_entry_t entries[] = {
ENTRY (JERRY_TYPE_NUMBER, jerry_create_number (-33.0)),
ENTRY (JERRY_TYPE_NUMBER, jerry_create_number (3)),
ENTRY (JERRY_TYPE_NUMBER, jerry_create_number_nan ()),
@@ -65,9 +68,7 @@ main (void)
ENTRY (JERRY_TYPE_NULL, jerry_create_null ()),
- ENTRY (JERRY_TYPE_FUNCTION, jerry_eval (test_eval_function,
- sizeof (test_eval_function) - 1,
- JERRY_PARSE_NO_OPTS)),
+ ENTRY (JERRY_TYPE_FUNCTION, jerry_eval (test_eval_function, sizeof (test_eval_function) - 1, JERRY_PARSE_NO_OPTS)),
ENTRY (JERRY_TYPE_FUNCTION, jerry_create_external_function (test_ext_function)),
ENTRY (JERRY_TYPE_STRING, jerry_create_string (test_eval_function)),
diff --git a/tests/unit-core/test-api.c b/tests/unit-core/test-api.c
index d3dff7c3..077a75b3 100644
--- a/tests/unit-core/test-api.c
+++ b/tests/unit-core/test-api.c
@@ -13,51 +13,50 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+#include "config.h"
#include "test-common.h"
-const jerry_char_t test_source[] = TEST_STRING_LITERAL (
- "function assert (arg) { "
- " if (!arg) { "
- " throw Error('Assert failed');"
- " } "
- "} "
- "this.t = 1; "
- "function f () { "
- "return this.t; "
- "} "
- "this.foo = f; "
- "this.bar = function (a) { "
- "return a + t; "
- "}; "
- "function A () { "
- "this.t = 12; "
- "} "
- "this.A = A; "
- "this.a = new A (); "
- "function call_external () { "
- " return this.external ('1', true); "
- "} "
- "function call_throw_test() { "
- " var catched = false; "
- " try { "
- " this.throw_test(); "
- " } catch (e) { "
- " catched = true; "
- " assert(e.name == 'TypeError'); "
- " assert(e.message == 'error'); "
- " } "
- " assert(catched); "
- "} "
- "function throw_reference_error() { "
- " throw new ReferenceError ();"
- "} "
- "p = {'alpha':32, 'bravo':false, 'charlie':{}, 'delta':123.45, 'echo':'foobar'};"
- "np = {}; Object.defineProperty (np, 'foxtrot', { "
- "get: function() { throw 'error'; }, enumerable: true }) "
-);
+const jerry_char_t test_source[] =
+ TEST_STRING_LITERAL ("function assert (arg) { "
+ " if (!arg) { "
+ " throw Error('Assert failed');"
+ " } "
+ "} "
+ "this.t = 1; "
+ "function f () { "
+ "return this.t; "
+ "} "
+ "this.foo = f; "
+ "this.bar = function (a) { "
+ "return a + t; "
+ "}; "
+ "function A () { "
+ "this.t = 12; "
+ "} "
+ "this.A = A; "
+ "this.a = new A (); "
+ "function call_external () { "
+ " return this.external ('1', true); "
+ "} "
+ "function call_throw_test() { "
+ " var catched = false; "
+ " try { "
+ " this.throw_test(); "
+ " } catch (e) { "
+ " catched = true; "
+ " assert(e.name == 'TypeError'); "
+ " assert(e.message == 'error'); "
+ " } "
+ " assert(catched); "
+ "} "
+ "function throw_reference_error() { "
+ " throw new ReferenceError ();"
+ "} "
+ "p = {'alpha':32, 'bravo':false, 'charlie':{}, 'delta':123.45, 'echo':'foobar'};"
+ "np = {}; Object.defineProperty (np, 'foxtrot', { "
+ "get: function() { throw 'error'; }, enumerable: true }) ");
bool test_api_is_free_callback_was_called = false;
@@ -80,9 +79,7 @@ handler (const jerry_call_info_t *call_info_p, /**< call information */
TEST_ASSERT (jerry_value_is_string (args_p[0]));
sz = jerry_get_string_size (args_p[0]);
TEST_ASSERT (sz == 1);
- sz = jerry_string_to_char_buffer (args_p[0],
- (jerry_char_t *) buffer,
- sz);
+ sz = jerry_string_to_char_buffer (args_p[0], (jerry_char_t *) buffer, sz);
TEST_ASSERT (sz == 1);
TEST_ASSERT (!strncmp (buffer, "1", (size_t) sz));
@@ -135,12 +132,11 @@ handler_construct_2_freecb (void *native_p, /**< native pointer */
/**
* Define a native pointer's type based on the C type and free callback.
*/
-#define JERRY_DEFINE_NATIVE_HANDLE_INFO(c_type, native_free_cb) \
- static const jerry_object_native_info_t JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (c_type) = \
- { \
- .free_cb = (jerry_object_native_free_callback_t) native_free_cb, \
- .number_of_references = 0, \
- .offset_of_references = 0, \
+#define JERRY_DEFINE_NATIVE_HANDLE_INFO(c_type, native_free_cb) \
+ static const jerry_object_native_info_t JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (c_type) = { \
+ .free_cb = (jerry_object_native_free_callback_t) native_free_cb, \
+ .number_of_references = 0, \
+ .offset_of_references = 0, \
}
JERRY_DEFINE_NATIVE_HANDLE_INFO (bind1, handler_construct_1_freecb);
@@ -180,8 +176,7 @@ handler_construct (const jerry_call_info_t *call_info_p, /**< call information *
/* Check that the native pointer was set. */
void *ptr = NULL;
bool is_ok = jerry_get_object_native_pointer (this_value, &ptr, &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind1));
- TEST_ASSERT (is_ok
- && (uintptr_t) ptr == (uintptr_t) 0x0000000000000000ull);
+ TEST_ASSERT (is_ok && (uintptr_t) ptr == (uintptr_t) 0x0000000000000000ull);
/* Set a second native pointer. */
jerry_set_object_native_pointer (this_value,
@@ -190,55 +185,47 @@ handler_construct (const jerry_call_info_t *call_info_p, /**< call information *
/* Check that a second native pointer was set. */
is_ok = jerry_get_object_native_pointer (this_value, &ptr, &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind2));
- TEST_ASSERT (is_ok
- && (uintptr_t) ptr == (uintptr_t) 0x0012345678abcdefull);
+ TEST_ASSERT (is_ok && (uintptr_t) ptr == (uintptr_t) 0x0012345678abcdefull);
/* Check that the first native pointer is still set. */
is_ok = jerry_get_object_native_pointer (this_value, &ptr, &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind1));
- TEST_ASSERT (is_ok
- && (uintptr_t) ptr == (uintptr_t) 0x0000000000000000ull);
+ TEST_ASSERT (is_ok && (uintptr_t) ptr == (uintptr_t) 0x0000000000000000ull);
return jerry_create_boolean (true);
} /* handler_construct */
/**
* Extended Magic Strings
*/
-#define JERRY_MAGIC_STRING_ITEMS \
- JERRY_MAGIC_STRING_DEF (GLOBAL, global) \
+#define JERRY_MAGIC_STRING_ITEMS \
+ JERRY_MAGIC_STRING_DEF (GLOBAL, global) \
JERRY_MAGIC_STRING_DEF (GREEK_ZERO_SIGN, \xed\xa0\x80\xed\xb6\x8a) \
JERRY_MAGIC_STRING_DEF (CONSOLE, console)
-#define JERRY_MAGIC_STRING_DEF(NAME, STRING) \
- static const char jerry_magic_string_ex_ ## NAME[] = # STRING;
+#define JERRY_MAGIC_STRING_DEF(NAME, STRING) static const char jerry_magic_string_ex_##NAME[] = #STRING;
JERRY_MAGIC_STRING_ITEMS
#undef JERRY_MAGIC_STRING_DEF
-const jerry_length_t magic_string_lengths[] =
-{
-#define JERRY_MAGIC_STRING_DEF(NAME, STRING) \
- (jerry_length_t) (sizeof (jerry_magic_string_ex_ ## NAME) - 1u),
+const jerry_length_t magic_string_lengths[] = {
+#define JERRY_MAGIC_STRING_DEF(NAME, STRING) (jerry_length_t) (sizeof (jerry_magic_string_ex_##NAME) - 1u),
JERRY_MAGIC_STRING_ITEMS
#undef JERRY_MAGIC_STRING_DEF
};
-const jerry_char_t *magic_string_items[] =
-{
-#define JERRY_MAGIC_STRING_DEF(NAME, STRING) \
- (const jerry_char_t *) jerry_magic_string_ex_ ## NAME,
+const jerry_char_t *magic_string_items[] = {
+#define JERRY_MAGIC_STRING_DEF(NAME, STRING) (const jerry_char_t *) jerry_magic_string_ex_##NAME,
JERRY_MAGIC_STRING_ITEMS
#undef JERRY_MAGIC_STRING_DEF
};
-static bool
-foreach (const jerry_value_t name, /**< field name */
- const jerry_value_t value, /**< field value */
- void *user_data) /**< user data */
+static bool foreach (const jerry_value_t name, /**< field name */
+ const jerry_value_t value, /**< field value */
+ void *user_data) /**< user data */
{
char str_buf_p[128];
jerry_size_t sz = jerry_string_to_char_buffer (name, (jerry_char_t *) str_buf_p, 128);
@@ -274,9 +261,7 @@ foreach (const jerry_value_t name, /**< field name */
else if (!strncmp (str_buf_p, "echo", (size_t) sz))
{
TEST_ASSERT (jerry_value_is_string (value));
- jerry_size_t echo_sz = jerry_string_to_char_buffer (value,
- (jerry_char_t *) str_buf_p,
- 128);
+ jerry_size_t echo_sz = jerry_string_to_char_buffer (value, (jerry_char_t *) str_buf_p, 128);
str_buf_p[echo_sz] = '\0';
TEST_ASSERT (!strncmp (str_buf_p, "foobar", (size_t) echo_sz));
return true;
@@ -357,9 +342,7 @@ test_syntax_error (const char *script_p, /**< source code to run */
const char *error_message_p, /**< error message */
bool run_script) /**< run script before checking the error message */
{
- jerry_value_t result_val = jerry_parse ((const jerry_char_t *) script_p,
- strlen (script_p),
- options_p);
+ jerry_value_t result_val = jerry_parse ((const jerry_char_t *) script_p, strlen (script_p), options_p);
if (run_script)
{
@@ -410,9 +393,7 @@ main (void)
jerry_init (JERRY_INIT_EMPTY);
- parsed_code_val = jerry_parse (test_source,
- sizeof (test_source) - 1,
- NULL);
+ parsed_code_val = jerry_parse (test_source, sizeof (test_source) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
res = jerry_run (parsed_code_val);
@@ -430,8 +411,7 @@ main (void)
/* Get global.t */
val_t = get_property (global_obj_val, "t");
TEST_ASSERT (!jerry_value_is_error (val_t));
- TEST_ASSERT (jerry_value_is_number (val_t)
- && jerry_get_number_value (val_t) == 1.0);
+ TEST_ASSERT (jerry_value_is_number (val_t) && jerry_get_number_value (val_t) == 1.0);
jerry_release_value (val_t);
/* Get global.foo */
@@ -444,8 +424,7 @@ main (void)
args[1] = jerry_create_number (2);
res = jerry_call_function (val_foo, jerry_create_undefined (), args, 2);
TEST_ASSERT (!jerry_value_is_error (res));
- TEST_ASSERT (jerry_value_is_number (res)
- && jerry_get_number_value (res) == 1.0);
+ TEST_ASSERT (jerry_value_is_number (res) && jerry_get_number_value (res) == 1.0);
jerry_release_value (res);
/* Get global.bar */
@@ -456,8 +435,7 @@ main (void)
/* Call bar (4, 2) */
res = jerry_call_function (val_bar, jerry_create_undefined (), args, 2);
TEST_ASSERT (!jerry_value_is_error (res));
- TEST_ASSERT (jerry_value_is_number (res)
- && jerry_get_number_value (res) == 5.0);
+ TEST_ASSERT (jerry_value_is_number (res) && jerry_get_number_value (res) == 5.0);
jerry_release_value (res);
jerry_release_value (val_bar);
@@ -511,8 +489,7 @@ main (void)
/* Get a.t */
res = get_property (val_a, "t");
TEST_ASSERT (!jerry_value_is_error (res));
- TEST_ASSERT (jerry_value_is_number (res)
- && jerry_get_number_value (res) == 12.0);
+ TEST_ASSERT (jerry_value_is_number (res) && jerry_get_number_value (res) == 12.0);
jerry_release_value (res);
/* foreach properties */
@@ -541,8 +518,7 @@ main (void)
/* Call a.foo () */
res = jerry_call_function (val_a_foo, val_a, NULL, 0);
TEST_ASSERT (!jerry_value_is_error (res));
- TEST_ASSERT (jerry_value_is_number (res)
- && jerry_get_number_value (res) == 12.0);
+ TEST_ASSERT (jerry_value_is_number (res) && jerry_get_number_value (res) == 12.0);
jerry_release_value (res);
jerry_release_value (val_a_foo);
@@ -550,8 +526,7 @@ main (void)
/* Create native handler bound function object and set it to 'external' variable */
external_func_val = jerry_create_external_function (handler);
- TEST_ASSERT (jerry_value_is_function (external_func_val)
- && jerry_value_is_constructor (external_func_val));
+ TEST_ASSERT (jerry_value_is_function (external_func_val) && jerry_value_is_constructor (external_func_val));
res = set_property (global_obj_val, "external", external_func_val);
TEST_ASSERT (!jerry_value_is_error (res));
@@ -575,8 +550,7 @@ main (void)
/* Create native handler bound function object and set it to 'external_construct' variable */
external_construct_val = jerry_create_external_function (handler_construct);
- TEST_ASSERT (jerry_value_is_function (external_construct_val)
- && jerry_value_is_constructor (external_construct_val));
+ TEST_ASSERT (jerry_value_is_function (external_construct_val) && jerry_value_is_constructor (external_construct_val));
res = set_property (global_obj_val, "external_construct", external_construct_val);
TEST_ASSERT (!jerry_value_is_error (res));
@@ -592,15 +566,13 @@ main (void)
/* Get 'value_field' of constructed object */
TEST_ASSERT (!jerry_value_is_error (val_value_field));
- TEST_ASSERT (jerry_value_is_boolean (val_value_field)
- && jerry_value_is_true (val_value_field));
+ TEST_ASSERT (jerry_value_is_boolean (val_value_field) && jerry_value_is_true (val_value_field));
jerry_release_value (val_value_field);
jerry_release_value (external_construct_val);
void *ptr = NULL;
is_ok = jerry_get_object_native_pointer (res, &ptr, &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind2));
- TEST_ASSERT (is_ok
- && (uintptr_t) ptr == (uintptr_t) 0x0012345678abcdefull);
+ TEST_ASSERT (is_ok && (uintptr_t) ptr == (uintptr_t) 0x0012345678abcdefull);
/* Passing NULL for info_p is allowed. */
is_ok = jerry_get_object_native_pointer (res, &ptr, NULL);
@@ -610,9 +582,7 @@ main (void)
/* Test: It is ok to set native pointer's free callback as NULL. */
jerry_value_t obj_freecb = jerry_create_object ();
- jerry_set_object_native_pointer (obj_freecb,
- (void *) 0x1234,
- &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind3));
+ jerry_set_object_native_pointer (obj_freecb, (void *) 0x1234, &JERRY_NATIVE_HANDLE_INFO_FOR_CTYPE (bind3));
jerry_release_value (obj_freecb);
@@ -700,8 +670,7 @@ main (void)
jerry_release_value (res);
jerry_value_t v_out = jerry_get_property_by_index (array_obj_val, 5);
- TEST_ASSERT (jerry_value_is_number (v_out)
- && jerry_get_number_value (v_out) == 10.5);
+ TEST_ASSERT (jerry_value_is_number (v_out) && jerry_get_number_value (v_out) == 10.5);
jerry_delete_property_by_index (array_obj_val, 5);
jerry_value_t v_und = jerry_get_property_by_index (array_obj_val, 5);
@@ -807,8 +776,7 @@ main (void)
res = jerry_call_function (val_t, jerry_create_undefined (), NULL, 0);
TEST_ASSERT (!jerry_value_is_error (res));
- TEST_ASSERT (jerry_value_is_number (res)
- && jerry_get_number_value (res) == 123.0);
+ TEST_ASSERT (jerry_value_is_number (res) && jerry_get_number_value (res) == 123.0);
jerry_release_value (res);
jerry_release_value (val_t);
@@ -823,8 +791,7 @@ main (void)
const jerry_char_t eval_code_src2[] = "\x0a \x0b \x0c \xc2\xa0 \xe2\x80\xa8 \xe2\x80\xa9 \xef\xbb\xbf 4321";
val_t = jerry_eval (eval_code_src2, sizeof (eval_code_src2) - 1, JERRY_PARSE_STRICT_MODE);
TEST_ASSERT (!jerry_value_is_error (val_t));
- TEST_ASSERT (jerry_value_is_number (val_t)
- && jerry_get_number_value (val_t) == 4321.0);
+ TEST_ASSERT (jerry_value_is_number (val_t) && jerry_get_number_value (val_t) == 4321.0);
jerry_release_value (val_t);
/* Test: number */
@@ -857,12 +824,7 @@ main (void)
jerry_release_value (parse_options.argument_list);
jerry_release_value (script_source);
- jerry_value_t func_args[3] =
- {
- jerry_create_number (4),
- jerry_create_number (6),
- jerry_create_number (-2)
- };
+ jerry_value_t func_args[3] = { jerry_create_number (4), jerry_create_number (6), jerry_create_number (-2) };
val_t = jerry_call_function (func_val, func_args[0], func_args, 3);
number_val = jerry_get_number_value (val_t);
@@ -877,16 +839,14 @@ main (void)
func_val = jerry_parse ((const jerry_char_t *) "", 0, &parse_options);
jerry_release_value (parse_options.argument_list);
- TEST_ASSERT (jerry_value_is_error (func_val)
- && jerry_get_error_type (func_val) == JERRY_ERROR_TYPE);
+ TEST_ASSERT (jerry_value_is_error (func_val) && jerry_get_error_type (func_val) == JERRY_ERROR_TYPE);
jerry_release_value (func_val);
script_source = jerry_create_number (4.5);
func_val = jerry_parse_value (script_source, NULL);
jerry_release_value (script_source);
- TEST_ASSERT (jerry_value_is_error (func_val)
- && jerry_get_error_type (func_val) == JERRY_ERROR_TYPE);
+ TEST_ASSERT (jerry_value_is_error (func_val) && jerry_get_error_type (func_val) == JERRY_ERROR_TYPE);
jerry_release_value (func_val);
jerry_cleanup ();
@@ -917,15 +877,11 @@ main (void)
{
jerry_init (JERRY_INIT_EMPTY);
const jerry_char_t scoped_src_p[] = "let a; this.b = 5";
- jerry_value_t parse_result = jerry_parse (scoped_src_p,
- sizeof (scoped_src_p) - 1,
- NULL);
+ jerry_value_t parse_result = jerry_parse (scoped_src_p, sizeof (scoped_src_p) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
jerry_release_value (parse_result);
- parse_result = jerry_parse (scoped_src_p,
- sizeof (scoped_src_p) - 1,
- NULL);
+ parse_result = jerry_parse (scoped_src_p, sizeof (scoped_src_p) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
jerry_value_t run_result = jerry_run (parse_result);
@@ -939,17 +895,13 @@ main (void)
jerry_release_value (parse_result);
/* The variable should have no effect on parsing. */
- parse_result = jerry_parse (scoped_src_p,
- sizeof (scoped_src_p) - 1,
- NULL);
+ parse_result = jerry_parse (scoped_src_p, sizeof (scoped_src_p) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
jerry_release_value (parse_result);
/* The already existing global binding should not affect a new lexical binding */
const jerry_char_t scoped_src2_p[] = "let b = 6; this.b + b";
- parse_result = jerry_parse (scoped_src2_p,
- sizeof (scoped_src2_p) - 1,
- NULL);
+ parse_result = jerry_parse (scoped_src2_p, sizeof (scoped_src2_p) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
run_result = jerry_run (parse_result);
TEST_ASSERT (jerry_value_is_number (run_result));
@@ -959,9 +911,7 @@ main (void)
/* Check restricted global property */
const jerry_char_t scoped_src3_p[] = "let undefined;";
- parse_result = jerry_parse (scoped_src3_p,
- sizeof (scoped_src3_p) - 1,
- NULL);
+ parse_result = jerry_parse (scoped_src3_p, sizeof (scoped_src3_p) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
run_result = jerry_run (parse_result);
TEST_ASSERT (jerry_value_is_error (run_result));
@@ -985,9 +935,7 @@ main (void)
jerry_release_value (global_obj);
const jerry_char_t scoped_src4_p[] = "let foo;";
- parse_result = jerry_parse (scoped_src4_p,
- sizeof (scoped_src4_p) - 1,
- NULL);
+ parse_result = jerry_parse (scoped_src4_p, sizeof (scoped_src4_p) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
run_result = jerry_run (parse_result);
TEST_ASSERT (jerry_value_is_error (run_result));
@@ -1009,9 +957,7 @@ main (void)
jerry_value_t old_realm = jerry_set_realm (new_realm_value);
const jerry_char_t scoped_src5_p[] = "let a;";
- parse_result = jerry_parse (scoped_src5_p,
- sizeof (scoped_src5_p) - 1,
- NULL);
+ parse_result = jerry_parse (scoped_src5_p, sizeof (scoped_src5_p) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
run_result = jerry_run (parse_result);
TEST_ASSERT (jerry_value_is_error (run_result));
@@ -1038,9 +984,7 @@ main (void)
old_realm = jerry_set_realm (new_realm_value);
const jerry_char_t scoped_src6_p[] = "let b;";
- parse_result = jerry_parse (scoped_src6_p,
- sizeof (scoped_src6_p) - 1,
- NULL);
+ parse_result = jerry_parse (scoped_src6_p, sizeof (scoped_src6_p) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
run_result = jerry_run (parse_result);
TEST_ASSERT (jerry_value_is_error (run_result));
@@ -1098,14 +1042,10 @@ main (void)
jerry_init (JERRY_INIT_SHOW_OPCODES);
uint32_t num_magic_string_items = (uint32_t) (sizeof (magic_string_items) / sizeof (jerry_char_t *));
- jerry_register_magic_strings (magic_string_items,
- num_magic_string_items,
- magic_string_lengths);
+ jerry_register_magic_strings (magic_string_items, num_magic_string_items, magic_string_lengths);
const jerry_char_t ms_code_src[] = "var global = {}; var console = [1]; var process = 1;";
- parsed_code_val = jerry_parse (ms_code_src,
- sizeof (ms_code_src) - 1,
- NULL);
+ parsed_code_val = jerry_parse (ms_code_src, sizeof (ms_code_src) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
res = jerry_run (parsed_code_val);
@@ -1130,9 +1070,7 @@ main (void)
jerry_release_value (args[0]);
const jerry_char_t test_magic_str_access_src[] = "'console'.charAt(6) == 'e'";
- res = jerry_eval (test_magic_str_access_src,
- sizeof (test_magic_str_access_src) - 1,
- JERRY_PARSE_NO_OPTS);
+ res = jerry_eval (test_magic_str_access_src, sizeof (test_magic_str_access_src) - 1, JERRY_PARSE_NO_OPTS);
TEST_ASSERT (jerry_value_is_boolean (res));
TEST_ASSERT (jerry_value_is_true (res));
diff --git a/tests/unit-core/test-arraybuffer.c b/tests/unit-core/test-arraybuffer.c
index f5668607..86777463 100644
--- a/tests/unit-core/test-arraybuffer.c
+++ b/tests/unit-core/test-arraybuffer.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
/**
@@ -44,14 +45,12 @@ assert_handler (const jerry_call_info_t *call_info_p, /**< call information */
{
JERRY_UNUSED (call_info_p);
- if (args_cnt > 0
- && jerry_value_is_true (args_p[0]))
+ if (args_cnt > 0 && jerry_value_is_true (args_p[0]))
{
return jerry_create_boolean (true);
}
- if (args_cnt > 1
- && jerry_value_is_string (args_p[1]))
+ if (args_cnt > 1 && jerry_value_is_string (args_p[1]))
{
jerry_length_t utf8_sz = jerry_get_string_size (args_p[1]);
TEST_ASSERT (utf8_sz <= 127); /* 127 is the expected max assert fail message size. */
@@ -72,14 +71,12 @@ assert_handler (const jerry_call_info_t *call_info_p, /**< call information */
static void
test_read_with_offset (uint8_t offset) /**< offset for buffer read. */
{
- const jerry_char_t eval_arraybuffer_src[] = TEST_STRING_LITERAL (
- "var array = new Uint8Array (15);"
- "for (var i = 0; i < array.length; i++) { array[i] = i * 2; };"
- "array.buffer"
- );
- jerry_value_t arraybuffer = jerry_eval (eval_arraybuffer_src,
- sizeof (eval_arraybuffer_src) - 1,
- JERRY_PARSE_STRICT_MODE);
+ const jerry_char_t eval_arraybuffer_src[] =
+ TEST_STRING_LITERAL ("var array = new Uint8Array (15);"
+ "for (var i = 0; i < array.length; i++) { array[i] = i * 2; };"
+ "array.buffer");
+ jerry_value_t arraybuffer =
+ jerry_eval (eval_arraybuffer_src, sizeof (eval_arraybuffer_src) - 1, JERRY_PARSE_STRICT_MODE);
TEST_ASSERT (!jerry_value_is_error (arraybuffer));
TEST_ASSERT (jerry_value_is_arraybuffer (arraybuffer));
@@ -104,7 +101,8 @@ test_read_with_offset (uint8_t offset) /**< offset for buffer read. */
/**
* Test ArrayBuffer 'write' api call with various offset values.
*/
-static void test_write_with_offset (uint8_t offset) /**< offset for buffer write. */
+static void
+test_write_with_offset (uint8_t offset) /**< offset for buffer write. */
{
{
jerry_value_t offset_val = jerry_create_number (offset);
@@ -113,9 +111,8 @@ static void test_write_with_offset (uint8_t offset) /**< offset for buffer write
}
const jerry_char_t eval_arraybuffer_src[] = "var array = new Uint8Array (15); array.buffer";
- jerry_value_t arraybuffer = jerry_eval (eval_arraybuffer_src,
- sizeof (eval_arraybuffer_src) - 1,
- JERRY_PARSE_STRICT_MODE);
+ jerry_value_t arraybuffer =
+ jerry_eval (eval_arraybuffer_src, sizeof (eval_arraybuffer_src) - 1, JERRY_PARSE_STRICT_MODE);
TEST_ASSERT (!jerry_value_is_error (arraybuffer));
TEST_ASSERT (jerry_value_is_arraybuffer (arraybuffer));
@@ -142,11 +139,8 @@ static void test_write_with_offset (uint8_t offset) /**< offset for buffer write
" var expected = (i - offset) * 3;"
" assert (array[i] == expected, 'calc check for: ' + i + ' was: ' + array[i] + ' should be: ' + expected);"
"};"
- "assert (array[15] === undefined, 'ArrayBuffer out of bounds index should return undefined value');"
- );
- jerry_value_t res = jerry_eval (eval_test_arraybuffer,
- sizeof (eval_test_arraybuffer) - 1,
- JERRY_PARSE_STRICT_MODE);
+ "assert (array[15] === undefined, 'ArrayBuffer out of bounds index should return undefined value');");
+ jerry_value_t res = jerry_eval (eval_test_arraybuffer, sizeof (eval_test_arraybuffer) - 1, JERRY_PARSE_STRICT_MODE);
jerry_release_value (res);
jerry_release_value (arraybuffer);
} /* test_write_with_offset */
@@ -228,9 +222,8 @@ main (void)
/* Test array buffer queries */
{
const jerry_char_t eval_arraybuffer_src[] = "new ArrayBuffer (10)";
- jerry_value_t eval_arraybuffer = jerry_eval (eval_arraybuffer_src,
- sizeof (eval_arraybuffer_src) - 1,
- JERRY_PARSE_STRICT_MODE);
+ jerry_value_t eval_arraybuffer =
+ jerry_eval (eval_arraybuffer_src, sizeof (eval_arraybuffer_src) - 1, JERRY_PARSE_STRICT_MODE);
TEST_ASSERT (!jerry_value_is_error (eval_arraybuffer));
TEST_ASSERT (jerry_value_is_arraybuffer (eval_arraybuffer));
TEST_ASSERT (jerry_get_arraybuffer_byte_length (eval_arraybuffer) == 10);
@@ -358,17 +351,14 @@ main (void)
register_js_value ("input_buffer", input_buffer);
jerry_release_value (input_buffer);
- const jerry_char_t eval_arraybuffer_src[] = TEST_STRING_LITERAL (
- "var array = new Uint8Array(input_buffer);"
- "for (var i = 0; i < array.length; i++)"
- "{"
- " array[i] = i * 2;"
- "};"
- "array.buffer"
- );
- jerry_value_t buffer = jerry_eval (eval_arraybuffer_src,
- sizeof (eval_arraybuffer_src) - 1,
- JERRY_PARSE_STRICT_MODE);
+ const jerry_char_t eval_arraybuffer_src[] = TEST_STRING_LITERAL ("var array = new Uint8Array(input_buffer);"
+ "for (var i = 0; i < array.length; i++)"
+ "{"
+ " array[i] = i * 2;"
+ "};"
+ "array.buffer");
+ jerry_value_t buffer =
+ jerry_eval (eval_arraybuffer_src, sizeof (eval_arraybuffer_src) - 1, JERRY_PARSE_STRICT_MODE);
TEST_ASSERT (!jerry_value_is_error (buffer));
TEST_ASSERT (jerry_value_is_arraybuffer (buffer));
@@ -400,11 +390,8 @@ main (void)
" assert(array[i] == expected, 'Array at index ' + i + ' was: ' + array[i] + ' should be: ' + expected);"
" sum += array[i]"
"};"
- "sum"
- );
- jerry_value_t res = jerry_eval (eval_test_arraybuffer,
- sizeof (eval_test_arraybuffer) - 1,
- JERRY_PARSE_STRICT_MODE);
+ "sum");
+ jerry_value_t res = jerry_eval (eval_test_arraybuffer, sizeof (eval_test_arraybuffer) - 1, JERRY_PARSE_STRICT_MODE);
TEST_ASSERT (jerry_value_is_number (res));
TEST_ASSERT (jerry_get_number_value (res) == sum);
jerry_release_value (res);
diff --git a/tests/unit-core/test-backtrace.c b/tests/unit-core/test-backtrace.c
index e5086429..1201ab80 100644
--- a/tests/unit-core/test-backtrace.c
+++ b/tests/unit-core/test-backtrace.c
@@ -13,8 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+
+#include "config.h"
#include "test-common.h"
static jerry_value_t
@@ -257,9 +258,7 @@ run (const char *resource_name_p, /**< resource name */
parse_options.options = JERRY_PARSE_HAS_RESOURCE;
parse_options.resource_name = jerry_create_string ((const jerry_char_t *) resource_name_p);
- jerry_value_t code = jerry_parse ((const jerry_char_t *) source_p,
- strlen (source_p),
- &parse_options);
+ jerry_value_t code = jerry_parse ((const jerry_char_t *) source_p, strlen (source_p), &parse_options);
jerry_release_value (parse_options.resource_name);
TEST_ASSERT (!jerry_value_is_error (code));
@@ -282,8 +281,7 @@ compare (jerry_value_t array, /**< array */
jerry_value_t value = jerry_get_property_by_index (array, index);
- TEST_ASSERT (!jerry_value_is_error (value)
- && jerry_value_is_string (value));
+ TEST_ASSERT (!jerry_value_is_error (value) && jerry_value_is_string (value));
TEST_ASSERT (jerry_get_string_size (value) == len);
@@ -319,8 +317,7 @@ test_get_backtrace_api_call (void)
jerry_value_t backtrace = run ("something.js", source_p);
- TEST_ASSERT (!jerry_value_is_error (backtrace)
- && jerry_value_is_array (backtrace));
+ TEST_ASSERT (!jerry_value_is_error (backtrace) && jerry_value_is_array (backtrace));
TEST_ASSERT (jerry_get_array_length (backtrace) == 4);
@@ -349,8 +346,7 @@ test_get_backtrace_api_call (void)
backtrace = run ("something_else.js", source_p);
- TEST_ASSERT (!jerry_value_is_error (backtrace)
- && jerry_value_is_array (backtrace));
+ TEST_ASSERT (!jerry_value_is_error (backtrace) && jerry_value_is_array (backtrace));
TEST_ASSERT (jerry_get_array_length (backtrace) == 2);
@@ -501,8 +497,7 @@ test_exception_backtrace (void)
jerry_release_value (name);
jerry_release_value (error);
- TEST_ASSERT (!jerry_value_is_error (backtrace)
- && jerry_value_is_array (backtrace));
+ TEST_ASSERT (!jerry_value_is_error (backtrace) && jerry_value_is_array (backtrace));
TEST_ASSERT (jerry_get_array_length (backtrace) == 3);
@@ -548,8 +543,7 @@ test_large_line_count (void)
jerry_release_value (name);
jerry_release_value (error);
- TEST_ASSERT (!jerry_value_is_error (backtrace)
- && jerry_value_is_array (backtrace));
+ TEST_ASSERT (!jerry_value_is_error (backtrace) && jerry_value_is_array (backtrace));
TEST_ASSERT (jerry_get_array_length (backtrace) == 1);
diff --git a/tests/unit-core/test-bigint.c b/tests/unit-core/test-bigint.c
index 3fb654d5..b4f0f329 100644
--- a/tests/unit-core/test-bigint.c
+++ b/tests/unit-core/test-bigint.c
@@ -14,6 +14,7 @@
*/
#include "jerryscript.h"
+
#include "test-common.h"
int
diff --git a/tests/unit-core/test-common.h b/tests/unit-core/test-common.h
index 1f3a89e1..67785c3f 100644
--- a/tests/unit-core/test-common.h
+++ b/tests/unit-core/test-common.h
@@ -16,62 +16,65 @@
#ifndef TEST_COMMON_H
#define TEST_COMMON_H
-#include "jerryscript-port.h"
-
#include <math.h>
#include <setjmp.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <stdarg.h>
#include <string.h>
+#include "jerryscript-port.h"
+
#define JERRY_UNUSED(x) ((void) (x))
-#define TEST_ASSERT(x) \
- do \
- { \
- if (JERRY_UNLIKELY (!(x))) \
- { \
- jerry_port_log (JERRY_LOG_LEVEL_ERROR, \
+#define TEST_ASSERT(x) \
+ do \
+ { \
+ if (JERRY_UNLIKELY (!(x))) \
+ { \
+ jerry_port_log (JERRY_LOG_LEVEL_ERROR, \
"TEST: Assertion '%s' failed at %s(%s):%lu.\n", \
- #x, \
- __FILE__, \
- __func__, \
- (unsigned long) __LINE__); \
- jerry_port_fatal (ERR_FAILED_INTERNAL_ASSERTION); \
- } \
+ #x, \
+ __FILE__, \
+ __func__, \
+ (unsigned long) __LINE__); \
+ jerry_port_fatal (ERR_FAILED_INTERNAL_ASSERTION); \
+ } \
} while (0)
-#define TEST_ASSERT_STR(EXPECTED, RESULT) \
- do \
- { \
- const char* __expected = (const char *) (EXPECTED); \
- const char* __result = (const char *) (RESULT); \
- if (strcmp(__expected, __result) != 0) \
- { \
- jerry_port_log (JERRY_LOG_LEVEL_ERROR, \
+#define TEST_ASSERT_STR(EXPECTED, RESULT) \
+ do \
+ { \
+ const char* __expected = (const char*) (EXPECTED); \
+ const char* __result = (const char*) (RESULT); \
+ if (strcmp (__expected, __result) != 0) \
+ { \
+ jerry_port_log (JERRY_LOG_LEVEL_ERROR, \
"TEST: String comparison failed at %s(%s):%lu.\n" \
- " Expected: '%s'\n Got: '%s'\n", \
- __FILE__, \
- __func__, \
- (unsigned long) __LINE__, \
- __expected, \
- __result); \
- jerry_port_fatal (ERR_FAILED_INTERNAL_ASSERTION); \
- \
- } \
+ " Expected: '%s'\n Got: '%s'\n", \
+ __FILE__, \
+ __func__, \
+ (unsigned long) __LINE__, \
+ __expected, \
+ __result); \
+ jerry_port_fatal (ERR_FAILED_INTERNAL_ASSERTION); \
+ } \
} while (0)
/**
* Test initialization statement that should be included
* at the beginning of main function in every unit test.
*/
-#define TEST_INIT() \
-do \
-{ \
- union { double d; unsigned u; } now = { .d = jerry_port_get_current_time () }; \
- srand (now.u); \
-} while (0)
+#define TEST_INIT() \
+ do \
+ { \
+ union \
+ { \
+ double d; \
+ unsigned u; \
+ } now = { .d = jerry_port_get_current_time () }; \
+ srand (now.u); \
+ } while (0)
/**
* Dummy macro to enable the breaking of long string literals into multiple
diff --git a/tests/unit-core/test-container-operation.c b/tests/unit-core/test-container-operation.c
index 50e72497..a0aca68a 100644
--- a/tests/unit-core/test-container-operation.c
+++ b/tests/unit-core/test-container-operation.c
@@ -14,6 +14,7 @@
*/
#include "jerryscript.h"
+
#include "test-common.h"
int
@@ -21,10 +22,8 @@ main (void)
{
jerry_init (JERRY_INIT_EMPTY);
- if (!jerry_is_feature_enabled (JERRY_FEATURE_MAP)
- || !jerry_is_feature_enabled (JERRY_FEATURE_SET)
- || !jerry_is_feature_enabled (JERRY_FEATURE_WEAKMAP)
- || !jerry_is_feature_enabled (JERRY_FEATURE_WEAKSET))
+ if (!jerry_is_feature_enabled (JERRY_FEATURE_MAP) || !jerry_is_feature_enabled (JERRY_FEATURE_SET)
+ || !jerry_is_feature_enabled (JERRY_FEATURE_WEAKMAP) || !jerry_is_feature_enabled (JERRY_FEATURE_WEAKSET))
{
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Containers are disabled!\n");
jerry_cleanup ();
@@ -37,7 +36,7 @@ main (void)
jerry_value_t key_str = jerry_create_string ((jerry_char_t *) "number");
jerry_value_t number = jerry_create_number (10);
- jerry_value_t args[2] = {key_str, number};
+ jerry_value_t args[2] = { key_str, number };
jerry_value_t result = jerry_container_operation (JERRY_CONTAINER_OP_SET, map, args, 2);
TEST_ASSERT (!jerry_value_is_error (result));
jerry_release_value (result);
@@ -56,7 +55,7 @@ main (void)
key_str = jerry_create_string ((jerry_char_t *) "number2");
number = jerry_create_number (11);
- jerry_value_t args2[2] = {key_str, number};
+ jerry_value_t args2[2] = { key_str, number };
result = jerry_container_operation (JERRY_CONTAINER_OP_SET, map, args2, 2);
jerry_release_value (result);
@@ -128,7 +127,7 @@ main (void)
jerry_value_t obj = jerry_create_object ();
number = jerry_create_number (10);
- jerry_value_t args4[2] = {obj, number};
+ jerry_value_t args4[2] = { obj, number };
result = jerry_container_operation (JERRY_CONTAINER_OP_SET, weak_map, args4, 2);
TEST_ASSERT (!jerry_value_is_error (result));
jerry_release_value (result);
@@ -165,7 +164,7 @@ main (void)
jerry_release_value (result);
// arguments is a error
- const char * const error_message_p = "Random error.";
+ const char *const error_message_p = "Random error.";
jerry_value_t error_val = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
jerry_value_t args3[2] = { error_val, error_val };
result = jerry_container_operation (JERRY_CONTAINER_OP_SET, map, args3, 2);
diff --git a/tests/unit-core/test-container.c b/tests/unit-core/test-container.c
index 3ddba3b5..b3c5b032 100644
--- a/tests/unit-core/test-container.c
+++ b/tests/unit-core/test-container.c
@@ -14,6 +14,7 @@
*/
#include "jerryscript.h"
+
#include "test-common.h"
static int global_counter;
@@ -27,8 +28,7 @@ native_free_callback (void *native_p, /**< native pointer */
global_counter++;
} /* native_free_callback */
-static const jerry_object_native_info_t native_info =
-{
+static const jerry_object_native_info_t native_info = {
.free_cb = native_free_callback,
.number_of_references = 0,
.offset_of_references = 0,
@@ -74,10 +74,8 @@ main (void)
{
jerry_init (JERRY_INIT_EMPTY);
- if (!jerry_is_feature_enabled (JERRY_FEATURE_MAP)
- || !jerry_is_feature_enabled (JERRY_FEATURE_SET)
- || !jerry_is_feature_enabled (JERRY_FEATURE_WEAKMAP)
- || !jerry_is_feature_enabled (JERRY_FEATURE_WEAKSET))
+ if (!jerry_is_feature_enabled (JERRY_FEATURE_MAP) || !jerry_is_feature_enabled (JERRY_FEATURE_SET)
+ || !jerry_is_feature_enabled (JERRY_FEATURE_WEAKMAP) || !jerry_is_feature_enabled (JERRY_FEATURE_WEAKSET))
{
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Containers are disabled!\n");
jerry_cleanup ();
@@ -143,20 +141,16 @@ main (void)
jerry_release_value (global_weakset);
jerry_release_value (empty_weakset);
- const jerry_char_t source[] = TEST_STRING_LITERAL (
- "(function () {\n"
- " var o1 = {}\n"
- " var o2 = {}\n"
- " var o3 = {}\n"
- " var wm = new WeakMap()\n"
- " wm.set(o1, o2)\n"
- " wm.set(o2, o3)\n"
- " return o3\n"
- "})()\n"
- );
- jerry_value_t result = jerry_eval (source,
- sizeof (source) - 1,
- JERRY_PARSE_NO_OPTS);
+ const jerry_char_t source[] = TEST_STRING_LITERAL ("(function () {\n"
+ " var o1 = {}\n"
+ " var o2 = {}\n"
+ " var o3 = {}\n"
+ " var wm = new WeakMap()\n"
+ " wm.set(o1, o2)\n"
+ " wm.set(o2, o3)\n"
+ " return o3\n"
+ "})()\n");
+ jerry_value_t result = jerry_eval (source, sizeof (source) - 1, JERRY_PARSE_NO_OPTS);
TEST_ASSERT (jerry_value_is_object (result));
jerry_set_object_native_pointer (result, (void *) &global_counter, &native_info);
diff --git a/tests/unit-core/test-context-data.c b/tests/unit-core/test-context-data.c
index d2ef7c57..d01f7133 100644
--- a/tests/unit-core/test-context-data.c
+++ b/tests/unit-core/test-context-data.c
@@ -13,8 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+
+#include "config.h"
#include "test-common.h"
static bool test_context_data1_new_called = false;
@@ -54,13 +55,10 @@ test_context_data1_finalize (void *user_data_p)
test_context_data1_finalize_called = true;
} /* test_context_data1_finalize */
-static const jerry_context_data_manager_t manager1 =
-{
- .init_cb = test_context_data1_new,
- .deinit_cb = test_context_data1_free,
- .finalize_cb = test_context_data1_finalize,
- .bytes_needed = sizeof (const char *)
-};
+static const jerry_context_data_manager_t manager1 = { .init_cb = test_context_data1_new,
+ .deinit_cb = test_context_data1_free,
+ .finalize_cb = test_context_data1_finalize,
+ .bytes_needed = sizeof (const char *) };
/* Context item 2 */
const char *string2 = "item2";
@@ -79,12 +77,9 @@ test_context_data2_free (void *user_data_p)
TEST_ASSERT ((*(const char **) user_data_p) == string2);
} /* test_context_data2_free */
-static const jerry_context_data_manager_t manager2 =
-{
- .init_cb = test_context_data2_new,
- .deinit_cb = test_context_data2_free,
- .bytes_needed = sizeof (const char *)
-};
+static const jerry_context_data_manager_t manager2 = { .init_cb = test_context_data2_new,
+ .deinit_cb = test_context_data2_free,
+ .bytes_needed = sizeof (const char *) };
/* Context item 3 */
@@ -95,8 +90,7 @@ test_context_data3_new (void *user_data_p)
test_context_data3_new_called = true;
} /* test_context_data3_new */
-static const jerry_context_data_manager_t manager3 =
-{
+static const jerry_context_data_manager_t manager3 = {
.init_cb = test_context_data3_new,
/* NULL is allowed: */
.deinit_cb = NULL,
@@ -129,13 +123,10 @@ test_context_data4_finalize (void *user_data_p)
TEST_ASSERT (user_data_p == NULL);
} /* test_context_data4_finalize */
-static const jerry_context_data_manager_t manager4 =
-{
- .init_cb = test_context_data4_new,
- .deinit_cb = test_context_data4_free,
- .finalize_cb = test_context_data4_finalize,
- .bytes_needed = 0
-};
+static const jerry_context_data_manager_t manager4 = { .init_cb = test_context_data4_new,
+ .deinit_cb = test_context_data4_free,
+ .finalize_cb = test_context_data4_finalize,
+ .bytes_needed = 0 };
int
main (void)
diff --git a/tests/unit-core/test-dataview.c b/tests/unit-core/test-dataview.c
index 30dd7a62..b377de69 100644
--- a/tests/unit-core/test-dataview.c
+++ b/tests/unit-core/test-dataview.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
int
@@ -39,7 +40,8 @@ main (void)
TEST_ASSERT (jerry_value_is_dataview (view1));
jerry_length_t byteOffset = 0;
- jerry_length_t byteLength = 0;;
+ jerry_length_t byteLength = 0;
+ ;
jerry_value_t internal_buffer = jerry_get_dataview_buffer (view1, &byteOffset, &byteLength);
TEST_ASSERT (jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, internal_buffer, arraybuffer));
TEST_ASSERT (byteOffset == 0);
@@ -88,9 +90,9 @@ main (void)
TEST_ASSERT (jerry_get_number_value (jerry_eval (get_src, sizeof (get_src) - 1, JERRY_PARSE_NO_OPTS)) == 255);
const jerry_char_t get_src_little_endian[] = "view2.getInt16 (0, true)";
- TEST_ASSERT (jerry_get_number_value (jerry_eval (get_src_little_endian,
- sizeof (get_src_little_endian) - 1,
- JERRY_PARSE_NO_OPTS)) == -256);
+ TEST_ASSERT (
+ jerry_get_number_value (jerry_eval (get_src_little_endian, sizeof (get_src_little_endian) - 1, JERRY_PARSE_NO_OPTS))
+ == -256);
/* Cleanup */
jerry_release_value (view2);
diff --git a/tests/unit-core/test-date-helpers.c b/tests/unit-core/test-date-helpers.c
index bba58edb..a9c3b30d 100644
--- a/tests/unit-core/test-date-helpers.c
+++ b/tests/unit-core/test-date-helpers.c
@@ -19,13 +19,11 @@
#include "test-common.h"
-#define MS_PER_DAY ((ecma_number_t) 86400000)
+#define MS_PER_DAY ((ecma_number_t) 86400000)
#define MS_PER_YEAR ((ecma_number_t) 365 * MS_PER_DAY)
-#define START_OF_GREGORIAN_CALENDAR ((ecma_number_t) (-1970 * MS_PER_YEAR \
- - (1970 / 4) * MS_PER_DAY \
- + (1970 / 100) * MS_PER_DAY \
- - (1970 / 400) * MS_PER_DAY \
- - MS_PER_DAY))
+#define START_OF_GREGORIAN_CALENDAR \
+ ((ecma_number_t) (-1970 * MS_PER_YEAR - (1970 / 4) * MS_PER_DAY + (1970 / 100) * MS_PER_DAY \
+ - (1970 / 400) * MS_PER_DAY - MS_PER_DAY))
/**
* Unit test's main function.
@@ -40,10 +38,8 @@ main (void)
TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY) == 1970);
TEST_ASSERT (ecma_date_year_from_time ((MS_PER_DAY) * (ecma_number_t) 365 - 1) == 1970);
TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) 365) == 1971);
- TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) (365 * (2015 - 1970)))
- == 2014);
- TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) (365.25 * (2015 - 1970)))
- == 2015);
+ TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) (365 * (2015 - 1970))) == 2014);
+ TEST_ASSERT (ecma_date_year_from_time (MS_PER_DAY * (ecma_number_t) (365.25 * (2015 - 1970))) == 2015);
TEST_ASSERT (ecma_date_year_from_time (-MS_PER_YEAR) == 1969);
TEST_ASSERT (ecma_date_year_from_time (-1970 * MS_PER_YEAR) == 1);
TEST_ASSERT (ecma_date_year_from_time (START_OF_GREGORIAN_CALENDAR) == 0);
diff --git a/tests/unit-core/test-error-callback.c b/tests/unit-core/test-error-callback.c
index a71f7b6f..7f551a70 100644
--- a/tests/unit-core/test-error-callback.c
+++ b/tests/unit-core/test-error-callback.c
@@ -22,7 +22,7 @@ static int error_object_created_callback_count = 0;
static void
error_object_created_callback (const jerry_value_t error_object_t, /**< new error object */
- void *user_p) /**< user pointer */
+ void *user_p) /**< user pointer */
{
TEST_ASSERT (!error_object_created_callback_is_running);
TEST_ASSERT (user_p == (void *) &error_object_created_callback_count);
@@ -72,7 +72,7 @@ main (void)
jerry_init (JERRY_INIT_EMPTY);
jerry_set_error_object_created_callback (error_object_created_callback,
- (void *) &error_object_created_callback_count);
+ (void *) &error_object_created_callback_count);
run_test ("var result = false\n"
"try {\n"
diff --git a/tests/unit-core/test-from-property-descriptor.c b/tests/unit-core/test-from-property-descriptor.c
index 89d5a5f2..8b9c646b 100644
--- a/tests/unit-core/test-from-property-descriptor.c
+++ b/tests/unit-core/test-from-property-descriptor.c
@@ -13,8 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+
+#include "config.h"
#include "test-common.h"
int
diff --git a/tests/unit-core/test-get-own-property.c b/tests/unit-core/test-get-own-property.c
index 489bd992..433d2dc5 100644
--- a/tests/unit-core/test-get-own-property.c
+++ b/tests/unit-core/test-get-own-property.c
@@ -1,4 +1,4 @@
- /* Copyright JS Foundation and other contributors, http://js.foundation
+/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/tests/unit-core/test-has-property.c b/tests/unit-core/test-has-property.c
index 7764f150..af309429 100644
--- a/tests/unit-core/test-has-property.c
+++ b/tests/unit-core/test-has-property.c
@@ -13,8 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+
+#include "config.h"
#include "test-common.h"
static void
diff --git a/tests/unit-core/test-internal-properties.c b/tests/unit-core/test-internal-properties.c
index b7f00c43..01afd256 100644
--- a/tests/unit-core/test-internal-properties.c
+++ b/tests/unit-core/test-internal-properties.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
int
@@ -184,12 +185,9 @@ main (void)
bool has_after_delete_result_5 = jerry_has_internal_property (object, internal_prop_name_2);
bool has_after_delete_result_6 = jerry_has_internal_property (object, internal_prop_name_3);
- TEST_ASSERT (jerry_value_is_boolean (has_after_delete_result_1)
- && !jerry_value_is_true (has_after_delete_result_1));
- TEST_ASSERT (jerry_value_is_boolean (has_after_delete_result_2)
- && !jerry_value_is_true (has_after_delete_result_2));
- TEST_ASSERT (jerry_value_is_boolean (has_after_delete_result_3)
- && !jerry_value_is_true (has_after_delete_result_3));
+ TEST_ASSERT (jerry_value_is_boolean (has_after_delete_result_1) && !jerry_value_is_true (has_after_delete_result_1));
+ TEST_ASSERT (jerry_value_is_boolean (has_after_delete_result_2) && !jerry_value_is_true (has_after_delete_result_2));
+ TEST_ASSERT (jerry_value_is_boolean (has_after_delete_result_3) && !jerry_value_is_true (has_after_delete_result_3));
TEST_ASSERT (has_after_delete_result_4);
TEST_ASSERT (has_after_delete_result_5);
TEST_ASSERT (has_after_delete_result_6);
diff --git a/tests/unit-core/test-is-eval-code.c b/tests/unit-core/test-is-eval-code.c
index 224356b5..0c07838d 100644
--- a/tests/unit-core/test-is-eval-code.c
+++ b/tests/unit-core/test-is-eval-code.c
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+#include "config.h"
#include "test-common.h"
static jerry_value_t
diff --git a/tests/unit-core/test-jmem.c b/tests/unit-core/test-jmem.c
index 6799939a..aedf1876 100644
--- a/tests/unit-core/test-jmem.c
+++ b/tests/unit-core/test-jmem.c
@@ -14,8 +14,8 @@
*/
#include "ecma-init-finalize.h"
-#include "jmem.h"
+#include "jmem.h"
#include "test-common.h"
#define BASIC_SIZE (64)
diff --git a/tests/unit-core/test-json.c b/tests/unit-core/test-json.c
index 8d6fba53..3f22784d 100644
--- a/tests/unit-core/test-json.c
+++ b/tests/unit-core/test-json.c
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+#include "config.h"
#include "test-common.h"
static jerry_value_t
diff --git a/tests/unit-core/test-lit-char-helpers.c b/tests/unit-core/test-lit-char-helpers.c
index 7374a7e1..16009dac 100644
--- a/tests/unit-core/test-lit-char-helpers.c
+++ b/tests/unit-core/test-lit-char-helpers.c
@@ -14,11 +14,11 @@
*/
#include "ecma-helpers.h"
-#include "lit-strings.h"
#include "ecma-init-finalize.h"
-#include "lit-char-helpers.h"
-#include "js-parser-internal.h"
+#include "js-parser-internal.h"
+#include "lit-char-helpers.h"
+#include "lit-strings.h"
#include "test-common.h"
static lit_code_point_t
@@ -48,8 +48,7 @@ lexer_hex_to_character (const uint8_t *source_p) /**< current source position */
return UINT32_MAX;
}
}
- }
- while (*source_p);
+ } while (*source_p);
return result;
} /* lexer_hex_to_character */
diff --git a/tests/unit-core/test-literal-storage.c b/tests/unit-core/test-literal-storage.c
index 2d3ff0b3..b5286338 100644
--- a/tests/unit-core/test-literal-storage.c
+++ b/tests/unit-core/test-literal-storage.c
@@ -15,6 +15,7 @@
#include "ecma-helpers.h"
#include "ecma-literal-storage.h"
+
#include "test-common.h"
/* Iterations count. */
diff --git a/tests/unit-core/test-mem-stats.c b/tests/unit-core/test-mem-stats.c
index d736c046..cfa1caeb 100644
--- a/tests/unit-core/test-mem-stats.c
+++ b/tests/unit-core/test-mem-stats.c
@@ -14,24 +14,22 @@
*/
#include "jerryscript.h"
+
#include "test-common.h"
-int main (void)
+int
+main (void)
{
if (!jerry_is_feature_enabled (JERRY_FEATURE_MEM_STATS))
{
return 0;
}
- const jerry_char_t test_source[] = TEST_STRING_LITERAL (
- "var a = 'hello';"
- "var b = 'world';"
- "var c = a + ' ' + b;"
- );
+ const jerry_char_t test_source[] = TEST_STRING_LITERAL ("var a = 'hello';"
+ "var b = 'world';"
+ "var c = a + ' ' + b;");
jerry_init (JERRY_INIT_EMPTY);
- jerry_value_t parsed_code_val = jerry_parse (test_source,
- sizeof (test_source) - 1,
- NULL);
+ jerry_value_t parsed_code_val = jerry_parse (test_source, sizeof (test_source) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
jerry_value_t res = jerry_run (parsed_code_val);
diff --git a/tests/unit-core/test-module-dynamic.c b/tests/unit-core/test-module-dynamic.c
index 9afb04bf..1c62e226 100644
--- a/tests/unit-core/test-module-dynamic.c
+++ b/tests/unit-core/test-module-dynamic.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
static int mode = 0;
@@ -79,9 +80,7 @@ module_import_callback (const jerry_value_t specifier, /* string value */
if (mode != 3)
{
- jerry_value_t compare_value = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL,
- user_value,
- global_user_value);
+ jerry_value_t compare_value = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, user_value, global_user_value);
TEST_ASSERT (jerry_value_is_true (compare_value));
jerry_release_value (compare_value);
diff --git a/tests/unit-core/test-module-import-meta.c b/tests/unit-core/test-module-import-meta.c
index 6208ddd0..9d5ded99 100644
--- a/tests/unit-core/test-module-import-meta.c
+++ b/tests/unit-core/test-module-import-meta.c
@@ -13,8 +13,9 @@
* limitations under the License.
*/
-#include "jerryscript.h"
#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
static int counter = 0;
@@ -69,8 +70,7 @@ test_syntax_error (const char *source_p, /**< source code */
const jerry_parse_options_t *options_p) /**< parse options */
{
jerry_value_t result_value = jerry_parse ((const jerry_char_t *) source_p, strlen (source_p), options_p);
- TEST_ASSERT (jerry_value_is_error (result_value)
- && jerry_get_error_type (result_value) == JERRY_ERROR_SYNTAX);
+ TEST_ASSERT (jerry_value_is_error (result_value) && jerry_get_error_type (result_value) == JERRY_ERROR_SYNTAX);
jerry_release_value (result_value);
} /* test_syntax_error */
@@ -120,11 +120,9 @@ main (void)
counter = 0;
- run_module (TEST_STRING_LITERAL ("assert(typeof import.meta === 'object')\n"),
- &parse_options);
+ run_module (TEST_STRING_LITERAL ("assert(typeof import.meta === 'object')\n"), &parse_options);
- run_module (TEST_STRING_LITERAL ("assert(Object.getPrototypeOf(import.meta) === null)\n"),
- &parse_options);
+ run_module (TEST_STRING_LITERAL ("assert(Object.getPrototypeOf(import.meta) === null)\n"), &parse_options);
run_module (TEST_STRING_LITERAL ("var meta = import.meta\n"
"assert(import.meta === meta)\n"
diff --git a/tests/unit-core/test-module.c b/tests/unit-core/test-module.c
index 9c0cbf4a..186bd6b8 100644
--- a/tests/unit-core/test-module.c
+++ b/tests/unit-core/test-module.c
@@ -16,6 +16,7 @@
#include <string.h>
#include "jerryscript.h"
+
#include "test-common.h"
static void
@@ -212,11 +213,8 @@ resolve_callback4 (const jerry_value_t specifier, /**< module specifier */
++counter;
- jerry_value_t exports[2] =
- {
- jerry_create_string ((const jerry_char_t *) "exp"),
- jerry_create_string ((const jerry_char_t *) "other_exp")
- };
+ jerry_value_t exports[2] = { jerry_create_string ((const jerry_char_t *) "exp"),
+ jerry_create_string ((const jerry_char_t *) "other_exp") };
jerry_value_t native_module = jerry_native_module_create (native_module_evaluate, exports, 2);
TEST_ASSERT (!jerry_value_is_error (native_module));
@@ -356,12 +354,10 @@ main (void)
jerry_parse_options_t module_parse_options;
module_parse_options.options = JERRY_PARSE_MODULE;
- jerry_char_t source1[] = TEST_STRING_LITERAL (
- "import a from '16_module.mjs'\n"
- "export * from '07_module.mjs'\n"
- "export * from '44_module.mjs'\n"
- "import * as b from '36_module.mjs'\n"
- );
+ jerry_char_t source1[] = TEST_STRING_LITERAL ("import a from '16_module.mjs'\n"
+ "export * from '07_module.mjs'\n"
+ "export * from '44_module.mjs'\n"
+ "import * as b from '36_module.mjs'\n");
module = jerry_parse (source1, sizeof (source1) - 1, &module_parse_options);
TEST_ASSERT (!jerry_value_is_error (module));
TEST_ASSERT (jerry_module_get_state (module) == JERRY_MODULE_STATE_UNLINKED);
@@ -399,10 +395,8 @@ main (void)
TEST_ASSERT (jerry_value_is_error (result));
jerry_release_value (result);
- jerry_char_t source2[] = TEST_STRING_LITERAL (
- "export let a = 6\n"
- "export let b = 8.5\n"
- );
+ jerry_char_t source2[] = TEST_STRING_LITERAL ("export let a = 6\n"
+ "export let b = 8.5\n");
module = jerry_parse (source2, sizeof (source2) - 1, &module_parse_options);
TEST_ASSERT (!jerry_value_is_error (module));
TEST_ASSERT (jerry_module_get_state (module) == JERRY_MODULE_STATE_UNLINKED);
@@ -484,8 +478,7 @@ main (void)
"import {exp, other_exp as other} from 'native.js'\n"
"import * as namespace from 'native.js'\n"
"if (exp !== 3.5 || other !== 'str') { throw 'Assertion failed!' }\n"
- "if (namespace.exp !== 3.5 || namespace.other_exp !== 'str') { throw 'Assertion failed!' }\n"
- );
+ "if (namespace.exp !== 3.5 || namespace.other_exp !== 'str') { throw 'Assertion failed!' }\n");
module = jerry_parse (source3, sizeof (source3) - 1, &module_parse_options);
TEST_ASSERT (!jerry_value_is_error (module));
TEST_ASSERT (jerry_module_get_state (module) == JERRY_MODULE_STATE_UNLINKED);
@@ -528,9 +521,7 @@ main (void)
counter = 0;
jerry_module_set_state_changed_callback (module_state_changed, (void *) &counter);
- jerry_char_t source4[] = TEST_STRING_LITERAL (
- "33.5\n"
- );
+ jerry_char_t source4[] = TEST_STRING_LITERAL ("33.5\n");
module = jerry_parse (source4, sizeof (source4) - 1, &module_parse_options);
result = jerry_module_link (module, NULL, NULL);
@@ -543,9 +534,7 @@ main (void)
jerry_release_value (module);
- jerry_char_t source5[] = TEST_STRING_LITERAL (
- "throw -5.5\n"
- );
+ jerry_char_t source5[] = TEST_STRING_LITERAL ("throw -5.5\n");
module = jerry_parse (source5, sizeof (source5) - 1, &module_parse_options);
result = jerry_module_link (module, NULL, NULL);
@@ -562,14 +551,11 @@ main (void)
TEST_ASSERT (counter == 4);
- jerry_char_t source6[] = TEST_STRING_LITERAL (
- "import a from 'self'\n"
- );
+ jerry_char_t source6[] = TEST_STRING_LITERAL ("import a from 'self'\n");
module = jerry_parse (source6, sizeof (source6) - 1, &module_parse_options);
result = jerry_module_link (module, resolve_callback5, NULL);
- TEST_ASSERT (jerry_value_is_error (result)
- && jerry_get_error_type (result) == JERRY_ERROR_SYNTAX);
+ TEST_ASSERT (jerry_value_is_error (result) && jerry_get_error_type (result) == JERRY_ERROR_SYNTAX);
jerry_release_value (result);
jerry_cleanup ();
diff --git a/tests/unit-core/test-native-callback-nested.c b/tests/unit-core/test-native-callback-nested.c
index 12bf0b23..66220b2e 100644
--- a/tests/unit-core/test-native-callback-nested.c
+++ b/tests/unit-core/test-native-callback-nested.c
@@ -13,25 +13,27 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
-static void native_cb2 (void)
+static void
+native_cb2 (void)
{
jerry_value_t array = jerry_create_array (100);
jerry_release_value (array);
} /* native_cb2 */
-static const jerry_object_native_info_t native_info2 =
-{
+static const jerry_object_native_info_t native_info2 = {
.free_cb = (jerry_object_native_free_callback_t) native_cb2,
.number_of_references = 0,
.offset_of_references = 0,
};
-static void native_cb (void)
+static void
+native_cb (void)
{
jerry_value_t array = jerry_create_array (100);
@@ -40,8 +42,7 @@ static void native_cb (void)
jerry_release_value (array);
} /* native_cb */
-static const jerry_object_native_info_t native_info =
-{
+static const jerry_object_native_info_t native_info = {
.free_cb = (jerry_object_native_free_callback_t) native_cb,
.number_of_references = 0,
.offset_of_references = 0,
diff --git a/tests/unit-core/test-native-instanceof.c b/tests/unit-core/test-native-instanceof.c
index f382fc16..5e899cee 100644
--- a/tests/unit-core/test-native-instanceof.c
+++ b/tests/unit-core/test-native-instanceof.c
@@ -14,14 +14,13 @@
*/
#include "jerryscript.h"
+
#include "test-common.h"
static const char instanceof_source[] = "var x = function(o, c) {return (o instanceof c);}; x";
static jerry_value_t
-external_function (const jerry_call_info_t *call_info_p,
- const jerry_value_t args_p[],
- const jerry_size_t args_count)
+external_function (const jerry_call_info_t *call_info_p, const jerry_value_t args_p[], const jerry_size_t args_count)
{
(void) call_info_p;
(void) args_p;
@@ -31,14 +30,10 @@ external_function (const jerry_call_info_t *call_info_p,
} /* external_function */
static void
-test_instanceof (jerry_value_t instanceof,
- jerry_value_t constructor)
+test_instanceof (jerry_value_t instanceof, jerry_value_t constructor)
{
jerry_value_t instance = jerry_construct_object (constructor, NULL, 0);
- jerry_value_t args[2] =
- {
- instance, constructor
- };
+ jerry_value_t args[2] = { instance, constructor };
jerry_value_t undefined = jerry_create_undefined ();
jerry_value_t result = jerry_call_function (instanceof, undefined, args, 2);
diff --git a/tests/unit-core/test-native-pointer.c b/tests/unit-core/test-native-pointer.c
index d2b6dcfb..d769004a 100644
--- a/tests/unit-core/test-native-pointer.c
+++ b/tests/unit-core/test-native-pointer.c
@@ -1,4 +1,4 @@
- /* Copyright JS Foundation and other contributors, http://js.foundation
+/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,22 +30,19 @@ native_free_callback (void *native_p, /**< native pointer */
global_counter++;
} /* native_free_callback */
-static const jerry_object_native_info_t native_info_1 =
-{
+static const jerry_object_native_info_t native_info_1 = {
.free_cb = native_free_callback,
.number_of_references = 0,
.offset_of_references = 0,
};
-static const jerry_object_native_info_t native_info_2 =
-{
+static const jerry_object_native_info_t native_info_2 = {
.free_cb = NULL,
.number_of_references = 0,
.offset_of_references = 0,
};
-static const jerry_object_native_info_t native_info_3 =
-{
+static const jerry_object_native_info_t native_info_3 = {
.free_cb = NULL,
.number_of_references = 0,
.offset_of_references = 0,
@@ -90,8 +87,7 @@ native_references_free_callback (void *native_p, /**< native pointer */
call_count++;
} /* native_references_free_callback */
-static const jerry_object_native_info_t native_info_4 =
-{
+static const jerry_object_native_info_t native_info_4 = {
.free_cb = native_references_free_callback,
.number_of_references = 3,
.offset_of_references = (uint16_t) offsetof (test_references_t, a),
@@ -127,12 +123,9 @@ set_references (test_references_t *refs_p, /**< native pointer */
jerry_native_pointer_set_reference (&refs_p->b, value2);
jerry_native_pointer_set_reference (&refs_p->c, value3);
- TEST_ASSERT (jerry_value_is_object (value1) ? jerry_value_is_object (refs_p->a)
- : jerry_value_is_string (refs_p->a));
- TEST_ASSERT (jerry_value_is_object (value2) ? jerry_value_is_object (refs_p->b)
- : jerry_value_is_string (refs_p->b));
- TEST_ASSERT (jerry_value_is_object (value3) ? jerry_value_is_object (refs_p->c)
- : jerry_value_is_string (refs_p->c));
+ TEST_ASSERT (jerry_value_is_object (value1) ? jerry_value_is_object (refs_p->a) : jerry_value_is_string (refs_p->a));
+ TEST_ASSERT (jerry_value_is_object (value2) ? jerry_value_is_object (refs_p->b) : jerry_value_is_string (refs_p->b));
+ TEST_ASSERT (jerry_value_is_object (value3) ? jerry_value_is_object (refs_p->c) : jerry_value_is_string (refs_p->c));
} /* set_references */
static void
diff --git a/tests/unit-core/test-newtarget.c b/tests/unit-core/test-newtarget.c
index f1df972c..861083fe 100644
--- a/tests/unit-core/test-newtarget.c
+++ b/tests/unit-core/test-newtarget.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
/**
@@ -150,9 +151,7 @@ main (void)
{
static const jerry_char_t test_source[] = TEST_STRING_LITERAL ("new Demo (1)");
- jerry_value_t parsed_code_val = jerry_parse (test_source,
- sizeof (test_source) - 1,
- NULL);
+ jerry_value_t parsed_code_val = jerry_parse (test_source, sizeof (test_source) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
jerry_value_t res = jerry_run (parsed_code_val);
@@ -165,9 +164,7 @@ main (void)
{
static const jerry_char_t test_source[] = TEST_STRING_LITERAL ("Demo (2)");
- jerry_value_t parsed_code_val = jerry_parse (test_source,
- sizeof (test_source) - 1,
- NULL);
+ jerry_value_t parsed_code_val = jerry_parse (test_source, sizeof (test_source) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
jerry_value_t res = jerry_run (parsed_code_val);
@@ -178,16 +175,12 @@ main (void)
}
{
- static const jerry_char_t test_source[] = TEST_STRING_LITERAL (
- "function base(arg) { new Demo (arg); };"
- "base (1);"
- "new base(1);"
- "new base(3);"
- );
-
- jerry_value_t parsed_code_val = jerry_parse (test_source,
- sizeof (test_source) - 1,
- NULL);
+ static const jerry_char_t test_source[] = TEST_STRING_LITERAL ("function base(arg) { new Demo (arg); };"
+ "base (1);"
+ "new base(1);"
+ "new base(3);");
+
+ jerry_value_t parsed_code_val = jerry_parse (test_source, sizeof (test_source) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
jerry_value_t res = jerry_run (parsed_code_val);
diff --git a/tests/unit-core/test-number-converter.c b/tests/unit-core/test-number-converter.c
index d026e027..71e5e712 100644
--- a/tests/unit-core/test-number-converter.c
+++ b/tests/unit-core/test-number-converter.c
@@ -115,7 +115,7 @@ main (void)
test_to_interger (-4294967297, -4294967297);
// few test-cases which return with error
- jerry_value_t error_val = jerry_create_error (JERRY_ERROR_TYPE, (const jerry_char_t *) "error");
+ jerry_value_t error_val = jerry_create_error (JERRY_ERROR_TYPE, (const jerry_char_t *) "error");
double number = jerry_value_as_integer (error_val);
jerry_release_value (error_val);
TEST_ASSERT (number == 0);
@@ -125,8 +125,8 @@ main (void)
TEST_ASSERT (number == 0);
jerry_release_value (error_val);
- error_val = jerry_eval ((const jerry_char_t *) "({ valueOf() { throw new TypeError('foo')}})",
- 44, JERRY_PARSE_NO_OPTS);
+ error_val =
+ jerry_eval ((const jerry_char_t *) "({ valueOf() { throw new TypeError('foo')}})", 44, JERRY_PARSE_NO_OPTS);
number = jerry_value_as_integer (error_val);
TEST_ASSERT (number == 0);
jerry_release_value (error_val);
diff --git a/tests/unit-core/test-number-to-int32.c b/tests/unit-core/test-number-to-int32.c
index 698376a5..3b2e3b7f 100644
--- a/tests/unit-core/test-number-to-int32.c
+++ b/tests/unit-core/test-number-to-int32.c
@@ -38,8 +38,7 @@ main (void)
{
TEST_INIT ();
- const uint32_test_case_t test_cases_uint32[] =
- {
+ const uint32_test_case_t test_cases_uint32[] = {
#define TEST_CASE(num, uint32) { num, uint32 }
TEST_CASE (1.0, 1),
TEST_CASE (0.0, 0),
@@ -60,15 +59,12 @@ main (void)
#undef TEST_CASE
};
- for (uint32_t i = 0;
- i < sizeof (test_cases_uint32) / sizeof (test_cases_uint32[0]);
- i++)
+ for (uint32_t i = 0; i < sizeof (test_cases_uint32) / sizeof (test_cases_uint32[0]); i++)
{
TEST_ASSERT (ecma_number_to_uint32 (test_cases_uint32[i].num) == test_cases_uint32[i].uint32_num);
}
- int32_test_case_t test_cases_int32[] =
- {
+ int32_test_case_t test_cases_int32[] = {
#define TEST_CASE(num, int32) { num, int32 }
TEST_CASE (1.0, 1),
TEST_CASE (0.0, 0),
@@ -95,9 +91,7 @@ main (void)
#undef TEST_CASE
};
- for (uint32_t i = 0;
- i < sizeof (test_cases_int32) / sizeof (test_cases_int32[0]);
- i++)
+ for (uint32_t i = 0; i < sizeof (test_cases_int32) / sizeof (test_cases_int32[0]); i++)
{
TEST_ASSERT (ecma_number_to_int32 (test_cases_int32[i].num) == test_cases_int32[i].int32_num);
}
diff --git a/tests/unit-core/test-number-to-string.c b/tests/unit-core/test-number-to-string.c
index 20c9203c..ed5fce22 100644
--- a/tests/unit-core/test-number-to-string.c
+++ b/tests/unit-core/test-number-to-string.c
@@ -26,39 +26,19 @@ main (void)
{
TEST_INIT ();
- const lit_utf8_byte_t *strings[] =
- {
- (const lit_utf8_byte_t *) "1",
- (const lit_utf8_byte_t *) "0.5",
- (const lit_utf8_byte_t *) "12345",
- (const lit_utf8_byte_t *) "12345.123",
- (const lit_utf8_byte_t *) "1e-45",
- (const lit_utf8_byte_t *) "-2.5e+38",
- (const lit_utf8_byte_t *) "NaN",
- (const lit_utf8_byte_t *) "Infinity",
- (const lit_utf8_byte_t *) "-Infinity",
- (const lit_utf8_byte_t *) "0",
- (const lit_utf8_byte_t *) "0",
+ const lit_utf8_byte_t *strings[] = {
+ (const lit_utf8_byte_t *) "1", (const lit_utf8_byte_t *) "0.5", (const lit_utf8_byte_t *) "12345",
+ (const lit_utf8_byte_t *) "12345.123", (const lit_utf8_byte_t *) "1e-45", (const lit_utf8_byte_t *) "-2.5e+38",
+ (const lit_utf8_byte_t *) "NaN", (const lit_utf8_byte_t *) "Infinity", (const lit_utf8_byte_t *) "-Infinity",
+ (const lit_utf8_byte_t *) "0", (const lit_utf8_byte_t *) "0",
};
- const ecma_number_t nums[] =
- {
- (ecma_number_t) 1.0,
- (ecma_number_t) 0.5,
- (ecma_number_t) 12345.0,
- (ecma_number_t) 12345.123,
- (ecma_number_t) 1.0e-45,
- (ecma_number_t) -2.5e+38,
- (ecma_number_t) NAN,
- (ecma_number_t) INFINITY,
- (ecma_number_t) -INFINITY,
- (ecma_number_t) +0.0,
- (ecma_number_t) -0.0
- };
+ const ecma_number_t nums[] = { (ecma_number_t) 1.0, (ecma_number_t) 0.5, (ecma_number_t) 12345.0,
+ (ecma_number_t) 12345.123, (ecma_number_t) 1.0e-45, (ecma_number_t) -2.5e+38,
+ (ecma_number_t) NAN, (ecma_number_t) INFINITY, (ecma_number_t) -INFINITY,
+ (ecma_number_t) + 0.0, (ecma_number_t) -0.0 };
- for (uint32_t i = 0;
- i < sizeof (nums) / sizeof (nums[0]);
- i++)
+ for (uint32_t i = 0; i < sizeof (nums) / sizeof (nums[0]); i++)
{
lit_utf8_byte_t str[64];
diff --git a/tests/unit-core/test-objects-foreach.c b/tests/unit-core/test-objects-foreach.c
index 1c5b0913..1cf6f487 100644
--- a/tests/unit-core/test-objects-foreach.c
+++ b/tests/unit-core/test-objects-foreach.c
@@ -14,6 +14,7 @@
*/
#include "jerryscript.h"
+
#include "test-common.h"
static bool
@@ -132,15 +133,15 @@ test_internal_prop (void)
static int test_data = 1;
-static void free_test_data (void *native_p, /**< native pointer */
- jerry_object_native_info_t *info_p) /**< native info */
+static void
+free_test_data (void *native_p, /**< native pointer */
+ jerry_object_native_info_t *info_p) /**< native info */
{
TEST_ASSERT ((int *) native_p == &test_data);
TEST_ASSERT (info_p->free_cb == free_test_data);
} /* free_test_data */
-static const jerry_object_native_info_t test_info =
-{
+static const jerry_object_native_info_t test_info = {
.free_cb = free_test_data,
.number_of_references = 0,
.offset_of_references = 0,
@@ -149,9 +150,7 @@ static const jerry_object_native_info_t test_info =
static const jerry_char_t strict_equal_source[] = "var x = function(a, b) {return a === b;}; x";
static bool
-find_test_object_by_data (const jerry_value_t candidate,
- void *object_data_p,
- void *context_p)
+find_test_object_by_data (const jerry_value_t candidate, void *object_data_p, void *context_p)
{
if (object_data_p == &test_data)
{
@@ -162,8 +161,7 @@ find_test_object_by_data (const jerry_value_t candidate,
} /* find_test_object_by_data */
static bool
-find_test_object_by_property (const jerry_value_t candidate,
- void *context_p)
+find_test_object_by_property (const jerry_value_t candidate, void *context_p)
{
jerry_value_t *args_p = (jerry_value_t *) context_p;
jerry_value_t result = jerry_has_property (candidate, args_p[0]);
@@ -191,9 +189,7 @@ main (void)
parse_options.options = JERRY_PARSE_STRICT_MODE;
/* Render strict-equal as a function. */
- jerry_value_t parse_result = jerry_parse (strict_equal_source,
- sizeof (strict_equal_source) - 1,
- &parse_options);
+ jerry_value_t parse_result = jerry_parse (strict_equal_source, sizeof (strict_equal_source) - 1, &parse_options);
TEST_ASSERT (!jerry_value_is_error (parse_result));
jerry_value_t strict_equal = jerry_run (parse_result);
TEST_ASSERT (!jerry_value_is_error (strict_equal));
@@ -207,7 +203,7 @@ main (void)
jerry_value_t found_object;
TEST_ASSERT (jerry_objects_foreach_by_native_info (&test_info, find_test_object_by_data, &found_object));
- jerry_value_t args[2] = {object, found_object};
+ jerry_value_t args[2] = { object, found_object };
/* Assert that the correct object was retrieved. */
jerry_value_t undefined = jerry_create_undefined ();
diff --git a/tests/unit-core/test-poolman.c b/tests/unit-core/test-poolman.c
index 478fc91c..9a737e79 100644
--- a/tests/unit-core/test-poolman.c
+++ b/tests/unit-core/test-poolman.c
@@ -25,15 +25,14 @@
#define JMEM_ALLOCATOR_INTERNAL
#include "jmem-allocator-internal.h"
-
#include "test-common.h"
/* Iterations count. */
const uint32_t test_iters = 1024;
/* Subiterations count. */
-#define TEST_MAX_SUB_ITERS 1024
-#define TEST_CHUNK_SIZE 8
+#define TEST_MAX_SUB_ITERS 1024
+#define TEST_CHUNK_SIZE 8
uint8_t *ptrs[TEST_MAX_SUB_ITERS];
uint8_t data[TEST_MAX_SUB_ITERS][TEST_CHUNK_SIZE];
diff --git a/tests/unit-core/test-promise-callback.c b/tests/unit-core/test-promise-callback.c
index b2303250..5c7bfda0 100644
--- a/tests/unit-core/test-promise-callback.c
+++ b/tests/unit-core/test-promise-callback.c
@@ -134,13 +134,10 @@ main (void)
jerry_init (JERRY_INIT_EMPTY);
- jerry_promise_event_filter_t filters = (JERRY_PROMISE_EVENT_FILTER_CREATE
- | JERRY_PROMISE_EVENT_FILTER_RESOLVE
- | JERRY_PROMISE_EVENT_FILTER_REJECT
- | JERRY_PROMISE_EVENT_FILTER_ERROR
- | JERRY_PROMISE_EVENT_FILTER_REACTION_JOB
- | JERRY_PROMISE_EVENT_FILTER_ASYNC_MAIN
- | JERRY_PROMISE_EVENT_FILTER_ASYNC_REACTION_JOB);
+ jerry_promise_event_filter_t filters =
+ (JERRY_PROMISE_EVENT_FILTER_CREATE | JERRY_PROMISE_EVENT_FILTER_RESOLVE | JERRY_PROMISE_EVENT_FILTER_REJECT
+ | JERRY_PROMISE_EVENT_FILTER_ERROR | JERRY_PROMISE_EVENT_FILTER_REACTION_JOB
+ | JERRY_PROMISE_EVENT_FILTER_ASYNC_MAIN | JERRY_PROMISE_EVENT_FILTER_ASYNC_REACTION_JOB);
jerry_promise_set_callback (filters, promise_callback, (void *) &user);
@@ -203,14 +200,12 @@ main (void)
/* Test Promise.resolve. */
static uint8_t events7[] = { C, RS, CP, BR, RS, AR, E };
- run_eval (events7,
- "Promise.resolve(4).then(() => {})\n");
+ run_eval (events7, "Promise.resolve(4).then(() => {})\n");
/* Test Promise.reject. */
static uint8_t events8[] = { C, RJ, RWH, CP, CHA, BR, RJ, RWH, AR, E };
- run_eval (events8,
- "Promise.reject(4).catch(() => { throw 'Error' })\n");
+ run_eval (events8, "Promise.reject(4).catch(() => { throw 'Error' })\n");
/* Test Promise.race without resolve */
static uint8_t events9[] = { C, C, C, CP, CP, E };
diff --git a/tests/unit-core/test-promise.c b/tests/unit-core/test-promise.c
index 66a0ae11..bf2fe390 100644
--- a/tests/unit-core/test-promise.c
+++ b/tests/unit-core/test-promise.c
@@ -13,21 +13,20 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
-static const jerry_char_t test_source[] = TEST_STRING_LITERAL (
- "var p1 = create_promise1();"
- "var p2 = create_promise2();"
- "p1.then(function(x) { "
- " assert(x==='resolved'); "
- "}); "
- "p2.catch(function(x) { "
- " assert(x==='rejected'); "
- "}); "
-);
+static const jerry_char_t test_source[] = TEST_STRING_LITERAL ("var p1 = create_promise1();"
+ "var p2 = create_promise2();"
+ "p1.then(function(x) { "
+ " assert(x==='resolved'); "
+ "}); "
+ "p2.catch(function(x) { "
+ " assert(x==='rejected'); "
+ "}); ");
static int count_in_assert = 0;
static jerry_value_t my_promise1;
@@ -44,7 +43,7 @@ create_promise1_handler (const jerry_call_info_t *call_info_p, /**< call informa
JERRY_UNUSED (args_p);
JERRY_UNUSED (args_cnt);
- jerry_value_t ret = jerry_create_promise ();
+ jerry_value_t ret = jerry_create_promise ();
my_promise1 = jerry_acquire_value (ret);
return ret;
@@ -59,7 +58,7 @@ create_promise2_handler (const jerry_call_info_t *call_info_p, /**< call informa
JERRY_UNUSED (args_p);
JERRY_UNUSED (args_cnt);
- jerry_value_t ret = jerry_create_promise ();
+ jerry_value_t ret = jerry_create_promise ();
my_promise2 = jerry_acquire_value (ret);
return ret;
@@ -74,8 +73,7 @@ assert_handler (const jerry_call_info_t *call_info_p, /**< call information */
count_in_assert++;
- if (args_cnt == 1
- && jerry_value_is_true (args_p[0]))
+ if (args_cnt == 1 && jerry_value_is_true (args_p[0]))
{
return jerry_create_boolean (true);
}
@@ -121,9 +119,7 @@ main (void)
register_js_function ("create_promise2", create_promise2_handler);
register_js_function ("assert", assert_handler);
- jerry_value_t parsed_code_val = jerry_parse (test_source,
- sizeof (test_source) - 1,
- NULL);
+ jerry_value_t parsed_code_val = jerry_parse (test_source, sizeof (test_source) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
jerry_value_t res = jerry_run (parsed_code_val);
diff --git a/tests/unit-core/test-proxy.c b/tests/unit-core/test-proxy.c
index 4c70672d..c72ceda1 100644
--- a/tests/unit-core/test-proxy.c
+++ b/tests/unit-core/test-proxy.c
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+#include "config.h"
#include "test-common.h"
/** Test in Proxy on C side. Equivalent test code in JS:
@@ -159,8 +159,7 @@ proxy_native_freecb (void *native_p, /**< native pointer */
data_p->value = -1;
} /* proxy_native_freecb */
-static const jerry_object_native_info_t proxy_native_info =
-{
+static const jerry_object_native_info_t proxy_native_info = {
.free_cb = proxy_native_freecb,
.number_of_references = 0,
.offset_of_references = 0,
@@ -247,9 +246,7 @@ main (void)
}
const jerry_char_t get_value_src[] = TEST_STRING_LITERAL ("pdemo.value");
- jerry_value_t parsed_get_code_val = jerry_parse (get_value_src,
- sizeof (get_value_src) - 1,
- NULL);
+ jerry_value_t parsed_get_code_val = jerry_parse (get_value_src, sizeof (get_value_src) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_get_code_val));
{
@@ -274,9 +271,7 @@ main (void)
}
const jerry_char_t set_value_src[] = TEST_STRING_LITERAL ("pdemo.value = 55");
- jerry_value_t parsed_set_code_val = jerry_parse (set_value_src,
- sizeof (set_value_src) - 1,
- NULL);
+ jerry_value_t parsed_set_code_val = jerry_parse (set_value_src, sizeof (set_value_src) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_set_code_val));
{
@@ -316,9 +311,7 @@ main (void)
const jerry_char_t has_value_src[] = TEST_STRING_LITERAL ("new Proxy({}, {\n"
" has: function(target, key) { throw 33 }\n"
"})");
- jerry_value_t parsed_has_code_val = jerry_parse (has_value_src,
- sizeof (has_value_src) - 1,
- NULL);
+ jerry_value_t parsed_has_code_val = jerry_parse (has_value_src, sizeof (has_value_src) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_has_code_val));
jerry_value_t res = jerry_run (parsed_has_code_val);
diff --git a/tests/unit-core/test-realm.c b/tests/unit-core/test-realm.c
index 17ba8ed0..2d4f7a49 100644
--- a/tests/unit-core/test-realm.c
+++ b/tests/unit-core/test-realm.c
@@ -235,9 +235,7 @@ main (void)
TEST_ASSERT (!jerry_value_is_error (result_value));
const char *script_p = "global2 = global1 - 1; Object.getPrototypeOf([])";
- jerry_value_t script_value = jerry_parse ((const jerry_char_t *) script_p,
- strlen (script_p),
- NULL);
+ jerry_value_t script_value = jerry_parse ((const jerry_char_t *) script_p, strlen (script_p), NULL);
TEST_ASSERT (!jerry_value_is_error (script_value));
jerry_set_realm (result_value);
diff --git a/tests/unit-core/test-regexp-dotall-unicode.c b/tests/unit-core/test-regexp-dotall-unicode.c
index d203ac63..516de1c8 100644
--- a/tests/unit-core/test-regexp-dotall-unicode.c
+++ b/tests/unit-core/test-regexp-dotall-unicode.c
@@ -1,4 +1,4 @@
- /* Copyright JS Foundation and other contributors, http://js.foundation
+/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/tests/unit-core/test-regression-3588.c b/tests/unit-core/test-regression-3588.c
index 3a3dcac6..9effe6a3 100644
--- a/tests/unit-core/test-regression-3588.c
+++ b/tests/unit-core/test-regression-3588.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
/**
@@ -61,14 +62,11 @@ main (void)
}
{
- static const jerry_char_t test_source[] = TEST_STRING_LITERAL (
- "class Sub1 extends Demo { constructor () { super (1); } };"
- "new Sub1 ()"
- );
-
- jerry_value_t parsed_code_val = jerry_parse (test_source,
- sizeof (test_source) - 1,
- NULL);
+ static const jerry_char_t test_source[] =
+ TEST_STRING_LITERAL ("class Sub1 extends Demo { constructor () { super (1); } };"
+ "new Sub1 ()");
+
+ jerry_value_t parsed_code_val = jerry_parse (test_source, sizeof (test_source) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
jerry_value_t result = jerry_run (parsed_code_val);
@@ -79,14 +77,10 @@ main (void)
}
{
- static const jerry_char_t test_source[] = TEST_STRING_LITERAL (
- "class Sub2 extends Demo { };"
- "new Sub2 (1)"
- );
-
- jerry_value_t parsed_code_val = jerry_parse (test_source,
- sizeof (test_source) - 1,
- NULL);
+ static const jerry_char_t test_source[] = TEST_STRING_LITERAL ("class Sub2 extends Demo { };"
+ "new Sub2 (1)");
+
+ jerry_value_t parsed_code_val = jerry_parse (test_source, sizeof (test_source) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
jerry_value_t result = jerry_run (parsed_code_val);
diff --git a/tests/unit-core/test-resource-name.c b/tests/unit-core/test-resource-name.c
index 2893bcc2..1ac1e99d 100644
--- a/tests/unit-core/test-resource-name.c
+++ b/tests/unit-core/test-resource-name.c
@@ -13,8 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+
+#include "config.h"
#include "test-common.h"
static jerry_value_t
@@ -71,9 +72,7 @@ main (void)
parse_options.resource_name = jerry_create_string ((jerry_char_t *) "demo1.js");
- jerry_value_t program = jerry_parse ((const jerry_char_t *) source_1,
- strlen (source_1),
- &parse_options);
+ jerry_value_t program = jerry_parse ((const jerry_char_t *) source_1, strlen (source_1), &parse_options);
TEST_ASSERT (!jerry_value_is_error (program));
jerry_value_t run_result = jerry_run (program);
@@ -81,9 +80,8 @@ main (void)
TEST_ASSERT (jerry_value_is_object (run_result));
jerry_value_t resource_value = jerry_get_resource_name (run_result);
- jerry_value_t compare_result = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL,
- resource_value,
- parse_options.resource_name);
+ jerry_value_t compare_result =
+ jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, resource_value, parse_options.resource_name);
TEST_ASSERT (jerry_value_is_true (compare_result));
jerry_release_value (compare_result);
@@ -105,9 +103,7 @@ main (void)
parse_options.resource_name = jerry_create_string ((const jerry_char_t *) "demo2.js");
- program = jerry_parse ((const jerry_char_t *) source_2,
- strlen (source_2),
- &parse_options);
+ program = jerry_parse ((const jerry_char_t *) source_2, strlen (source_2), &parse_options);
TEST_ASSERT (!jerry_value_is_error (program));
run_result = jerry_run (program);
@@ -132,9 +128,7 @@ main (void)
parse_options.options = JERRY_PARSE_MODULE | JERRY_PARSE_HAS_RESOURCE;
parse_options.resource_name = jerry_create_string ((const jerry_char_t *) "demo3.js");
- program = jerry_parse ((const jerry_char_t *) source_3,
- strlen (source_3),
- &parse_options);
+ program = jerry_parse ((const jerry_char_t *) source_3, strlen (source_3), &parse_options);
TEST_ASSERT (!jerry_value_is_error (program));
resource_value = jerry_get_resource_name (program);
@@ -174,9 +168,7 @@ main (void)
parse_options.options = JERRY_PARSE_HAS_RESOURCE;
parse_options.resource_name = jerry_create_string ((jerry_char_t *) "demo4.js");
- program = jerry_parse ((const jerry_char_t *) source_4,
- strlen (source_4),
- &parse_options);
+ program = jerry_parse ((const jerry_char_t *) source_4, strlen (source_4), &parse_options);
TEST_ASSERT (!jerry_value_is_error (program));
run_result = jerry_run (program);
@@ -199,9 +191,7 @@ main (void)
parse_options.user_value = jerry_create_object ();
parse_options.resource_name = jerry_create_string ((jerry_char_t *) "demo5.js");
- program = jerry_parse ((const jerry_char_t *) source_5,
- strlen (source_5),
- &parse_options);
+ program = jerry_parse ((const jerry_char_t *) source_5, strlen (source_5), &parse_options);
TEST_ASSERT (!jerry_value_is_error (program));
resource_value = jerry_get_resource_name (program);
@@ -219,9 +209,7 @@ main (void)
parse_options.options = JERRY_PARSE_HAS_RESOURCE;
parse_options.resource_name = jerry_create_string ((jerry_char_t *) "demo6.js");
- program = jerry_parse ((const jerry_char_t *) source_6,
- strlen (source_6),
- &parse_options);
+ program = jerry_parse ((const jerry_char_t *) source_6, strlen (source_6), &parse_options);
if (!jerry_value_is_error (program))
{
resource_value = jerry_get_resource_name (program);
diff --git a/tests/unit-core/test-script-user-value.c b/tests/unit-core/test-script-user-value.c
index 67a5bd20..7c473bab 100644
--- a/tests/unit-core/test-script-user-value.c
+++ b/tests/unit-core/test-script-user-value.c
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+#include "config.h"
#include "test-common.h"
static jerry_value_t user_values[4];
@@ -31,9 +31,7 @@ test_parse (const char *source_p, /**< source code */
{
options_p->user_value = user_values[i];
- jerry_value_t result = jerry_parse ((const jerry_char_t *) source_p,
- strlen (source_p),
- options_p);
+ jerry_value_t result = jerry_parse ((const jerry_char_t *) source_p, strlen (source_p), options_p);
TEST_ASSERT (!jerry_value_is_error (result));
if (run_code)
@@ -45,9 +43,7 @@ test_parse (const char *source_p, /**< source code */
}
jerry_value_t user_value = jerry_get_user_value (result);
- jerry_value_t compare_value = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL,
- user_value,
- user_values[i]);
+ jerry_value_t compare_value = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, user_value, user_values[i]);
TEST_ASSERT (jerry_value_is_true (compare_value));
@@ -69,9 +65,7 @@ test_parse_function (const char *source_p, /**< source code */
{
options_p->user_value = user_values[i];
- jerry_value_t result = jerry_parse ((const jerry_char_t *) source_p,
- strlen (source_p),
- options_p);
+ jerry_value_t result = jerry_parse ((const jerry_char_t *) source_p, strlen (source_p), options_p);
TEST_ASSERT (!jerry_value_is_error (result));
if (run_code)
@@ -85,9 +79,7 @@ test_parse_function (const char *source_p, /**< source code */
}
jerry_value_t user_value = jerry_get_user_value (result);
- jerry_value_t compare_value = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL,
- user_value,
- user_values[i]);
+ jerry_value_t compare_value = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, user_value, user_values[i]);
TEST_ASSERT (jerry_value_is_true (compare_value));
diff --git a/tests/unit-core/test-snapshot.c b/tests/unit-core/test-snapshot.c
index 1a3a6fdd..d4e4cc59 100644
--- a/tests/unit-core/test-snapshot.c
+++ b/tests/unit-core/test-snapshot.c
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+#include "config.h"
#include "test-common.h"
/**
@@ -31,27 +31,18 @@
/**
* Magic strings
*/
-static const jerry_char_t *magic_strings[] =
-{
- (const jerry_char_t *) " ",
- (const jerry_char_t *) "a",
- (const jerry_char_t *) "b",
- (const jerry_char_t *) "c",
- (const jerry_char_t *) "from",
- (const jerry_char_t *) "func",
- (const jerry_char_t *) "string",
- (const jerry_char_t *) "snapshot"
-};
+static const jerry_char_t *magic_strings[] = { (const jerry_char_t *) " ", (const jerry_char_t *) "a",
+ (const jerry_char_t *) "b", (const jerry_char_t *) "c",
+ (const jerry_char_t *) "from", (const jerry_char_t *) "func",
+ (const jerry_char_t *) "string", (const jerry_char_t *) "snapshot" };
/**
* Magic string lengths
*/
-static const jerry_length_t magic_string_lengths[] =
-{
- 1, 1, 1, 1, 4, 4, 6, 8
-};
+static const jerry_length_t magic_string_lengths[] = { 1, 1, 1, 1, 4, 4, 6, 8 };
-static void test_function_snapshot (void)
+static void
+test_function_snapshot (void)
{
/* function to snapshot */
if (!jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE)
@@ -71,20 +62,15 @@ static void test_function_snapshot (void)
parse_options.options = JERRY_PARSE_HAS_ARGUMENT_LIST;
parse_options.argument_list = jerry_create_string ((const jerry_char_t *) "a, b");
- jerry_value_t parse_result = jerry_parse (code_to_snapshot,
- sizeof (code_to_snapshot) - 1,
- &parse_options);
+ jerry_value_t parse_result = jerry_parse (code_to_snapshot, sizeof (code_to_snapshot) - 1, &parse_options);
TEST_ASSERT (!jerry_value_is_error (parse_result));
- jerry_value_t generate_result = jerry_generate_snapshot (parse_result,
- 0,
- function_snapshot_buffer,
- SNAPSHOT_BUFFER_SIZE);
+ jerry_value_t generate_result =
+ jerry_generate_snapshot (parse_result, 0, function_snapshot_buffer, SNAPSHOT_BUFFER_SIZE);
jerry_release_value (parse_result);
jerry_release_value (parse_options.argument_list);
- TEST_ASSERT (!jerry_value_is_error (generate_result)
- && jerry_value_is_number (generate_result));
+ TEST_ASSERT (!jerry_value_is_error (generate_result) && jerry_value_is_number (generate_result));
size_t function_snapshot_size = (size_t) jerry_get_number_value (generate_result);
jerry_release_value (generate_result);
@@ -122,7 +108,8 @@ static void test_function_snapshot (void)
jerry_cleanup ();
} /* test_function_snapshot */
-static void arguments_test_exec_snapshot (uint32_t *snapshot_p, size_t snapshot_size, uint32_t exec_snapshot_flags)
+static void
+arguments_test_exec_snapshot (uint32_t *snapshot_p, size_t snapshot_size, uint32_t exec_snapshot_flags)
{
jerry_init (JERRY_INIT_EMPTY);
jerry_value_t res = jerry_exec_snapshot (snapshot_p, snapshot_size, 0, exec_snapshot_flags, NULL);
@@ -135,37 +122,30 @@ static void arguments_test_exec_snapshot (uint32_t *snapshot_p, size_t snapshot_
jerry_cleanup ();
} /* arguments_test_exec_snapshot */
-static void test_function_arguments_snapshot (void)
+static void
+test_function_arguments_snapshot (void)
{
- if (jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE)
- && jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_EXEC))
+ if (jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE) && jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_EXEC))
{
static uint32_t arguments_snapshot_buffer[SNAPSHOT_BUFFER_SIZE];
- const jerry_char_t code_to_snapshot[] = TEST_STRING_LITERAL (
- "function f(a,b,c) {"
- " arguments[0]++;"
- " arguments[1]++;"
- " arguments[2]++;"
- " return a + b + c;"
- "}"
- "f(3,4,5);"
- );
+ const jerry_char_t code_to_snapshot[] = TEST_STRING_LITERAL ("function f(a,b,c) {"
+ " arguments[0]++;"
+ " arguments[1]++;"
+ " arguments[2]++;"
+ " return a + b + c;"
+ "}"
+ "f(3,4,5);");
jerry_init (JERRY_INIT_EMPTY);
- jerry_value_t parse_result = jerry_parse (code_to_snapshot,
- sizeof (code_to_snapshot) - 1,
- NULL);
+ jerry_value_t parse_result = jerry_parse (code_to_snapshot, sizeof (code_to_snapshot) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
- jerry_value_t generate_result= jerry_generate_snapshot (parse_result,
- 0,
- arguments_snapshot_buffer,
- SNAPSHOT_BUFFER_SIZE);
+ jerry_value_t generate_result =
+ jerry_generate_snapshot (parse_result, 0, arguments_snapshot_buffer, SNAPSHOT_BUFFER_SIZE);
jerry_release_value (parse_result);
- TEST_ASSERT (!jerry_value_is_error (generate_result)
- && jerry_value_is_number (generate_result));
+ TEST_ASSERT (!jerry_value_is_error (generate_result) && jerry_value_is_number (generate_result));
size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
jerry_release_value (generate_result);
@@ -177,7 +157,8 @@ static void test_function_arguments_snapshot (void)
}
} /* test_function_arguments_snapshot */
-static void test_exec_snapshot (uint32_t *snapshot_p, size_t snapshot_size, uint32_t exec_snapshot_flags)
+static void
+test_exec_snapshot (uint32_t *snapshot_p, size_t snapshot_size, uint32_t exec_snapshot_flags)
{
char string_data[32];
@@ -201,32 +182,24 @@ static void test_exec_snapshot (uint32_t *snapshot_p, size_t snapshot_size, uint
jerry_cleanup ();
} /* test_exec_snapshot */
-static void test_snapshot_with_user (void)
+static void
+test_snapshot_with_user (void)
{
- if (jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE)
- && jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_EXEC))
+ if (jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE) && jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_EXEC))
{
static uint32_t snapshot_buffer[SNAPSHOT_BUFFER_SIZE];
- const jerry_char_t code_to_snapshot[] = TEST_STRING_LITERAL (
- "function f() {}\n"
- "f"
- );
+ const jerry_char_t code_to_snapshot[] = TEST_STRING_LITERAL ("function f() {}\n"
+ "f");
jerry_init (JERRY_INIT_EMPTY);
- jerry_value_t parse_result = jerry_parse (code_to_snapshot,
- sizeof (code_to_snapshot) - 1,
- NULL);
+ jerry_value_t parse_result = jerry_parse (code_to_snapshot, sizeof (code_to_snapshot) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
- jerry_value_t generate_result = jerry_generate_snapshot (parse_result,
- 0,
- snapshot_buffer,
- SNAPSHOT_BUFFER_SIZE);
+ jerry_value_t generate_result = jerry_generate_snapshot (parse_result, 0, snapshot_buffer, SNAPSHOT_BUFFER_SIZE);
jerry_release_value (parse_result);
- TEST_ASSERT (!jerry_value_is_error (generate_result)
- && jerry_value_is_number (generate_result));
+ TEST_ASSERT (!jerry_value_is_error (generate_result) && jerry_value_is_number (generate_result));
size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
jerry_release_value (generate_result);
@@ -254,15 +227,12 @@ static void test_snapshot_with_user (void)
JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE,
&snapshot_exec_options);
- TEST_ASSERT (!jerry_value_is_error (result)
- && jerry_value_is_function (result));
+ TEST_ASSERT (!jerry_value_is_error (result) && jerry_value_is_function (result));
jerry_value_t user_value = jerry_get_user_value (result);
jerry_release_value (result);
- result = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL,
- user_value,
- snapshot_exec_options.user_value);
+ result = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, user_value, snapshot_exec_options.user_value);
TEST_ASSERT (jerry_value_is_true (result));
@@ -281,36 +251,28 @@ main (void)
TEST_INIT ();
/* Static snapshot */
- if (jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE)
- && jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_EXEC))
+ if (jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE) && jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_EXEC))
{
static uint32_t snapshot_buffer[SNAPSHOT_BUFFER_SIZE];
- const jerry_char_t code_to_snapshot[] = TEST_STRING_LITERAL (
- "function func(a, b, c) {"
- " c = 'snapshot';"
- " return arguments[0] + ' ' + b + ' ' + arguments[2];"
- "};"
- "func('string', 'from');"
- );
+ const jerry_char_t code_to_snapshot[] = TEST_STRING_LITERAL ("function func(a, b, c) {"
+ " c = 'snapshot';"
+ " return arguments[0] + ' ' + b + ' ' + arguments[2];"
+ "};"
+ "func('string', 'from');");
jerry_init (JERRY_INIT_EMPTY);
jerry_register_magic_strings (magic_strings,
sizeof (magic_string_lengths) / sizeof (jerry_length_t),
magic_string_lengths);
- jerry_value_t parse_result = jerry_parse (code_to_snapshot,
- sizeof (code_to_snapshot) - 1,
- NULL);
+ jerry_value_t parse_result = jerry_parse (code_to_snapshot, sizeof (code_to_snapshot) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
- jerry_value_t generate_result = jerry_generate_snapshot (parse_result,
- JERRY_SNAPSHOT_SAVE_STATIC,
- snapshot_buffer,
- SNAPSHOT_BUFFER_SIZE);
+ jerry_value_t generate_result =
+ jerry_generate_snapshot (parse_result, JERRY_SNAPSHOT_SAVE_STATIC, snapshot_buffer, SNAPSHOT_BUFFER_SIZE);
jerry_release_value (parse_result);
- TEST_ASSERT (!jerry_value_is_error (generate_result)
- && jerry_value_is_number (generate_result));
+ TEST_ASSERT (!jerry_value_is_error (generate_result) && jerry_value_is_number (generate_result));
size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
jerry_release_value (generate_result);
@@ -326,8 +288,7 @@ main (void)
}
/* Merge snapshot */
- if (jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE)
- && jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_EXEC))
+ if (jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE) && jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_EXEC))
{
static uint32_t snapshot_buffer_0[SNAPSHOT_BUFFER_SIZE];
static uint32_t snapshot_buffer_1[SNAPSHOT_BUFFER_SIZE];
@@ -338,19 +299,13 @@ main (void)
jerry_init (JERRY_INIT_EMPTY);
- jerry_value_t parse_result = jerry_parse (code_to_snapshot1,
- sizeof (code_to_snapshot1) - 1,
- NULL);
+ jerry_value_t parse_result = jerry_parse (code_to_snapshot1, sizeof (code_to_snapshot1) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
- jerry_value_t generate_result = jerry_generate_snapshot (parse_result,
- 0,
- snapshot_buffer_0,
- SNAPSHOT_BUFFER_SIZE);
+ jerry_value_t generate_result = jerry_generate_snapshot (parse_result, 0, snapshot_buffer_0, SNAPSHOT_BUFFER_SIZE);
jerry_release_value (parse_result);
- TEST_ASSERT (!jerry_value_is_error (generate_result)
- && jerry_value_is_number (generate_result));
+ TEST_ASSERT (!jerry_value_is_error (generate_result) && jerry_value_is_number (generate_result));
snapshot_sizes[0] = (size_t) jerry_get_number_value (generate_result);
jerry_release_value (generate_result);
@@ -361,19 +316,13 @@ main (void)
jerry_init (JERRY_INIT_EMPTY);
- parse_result = jerry_parse (code_to_snapshot2,
- sizeof (code_to_snapshot2) - 1,
- NULL);
+ parse_result = jerry_parse (code_to_snapshot2, sizeof (code_to_snapshot2) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
- generate_result = jerry_generate_snapshot (parse_result,
- 0,
- snapshot_buffer_1,
- SNAPSHOT_BUFFER_SIZE);
+ generate_result = jerry_generate_snapshot (parse_result, 0, snapshot_buffer_1, SNAPSHOT_BUFFER_SIZE);
jerry_release_value (parse_result);
- TEST_ASSERT (!jerry_value_is_error (generate_result)
- && jerry_value_is_number (generate_result));
+ TEST_ASSERT (!jerry_value_is_error (generate_result) && jerry_value_is_number (generate_result));
snapshot_sizes[1] = (size_t) jerry_get_number_value (generate_result);
jerry_release_value (generate_result);
@@ -431,15 +380,11 @@ main (void)
static uint32_t literal_snapshot_buffer[SNAPSHOT_BUFFER_SIZE];
static const jerry_char_t code_for_c_format[] = "var object = { aa:'fo\" o\\n \\\\', Bb:'max', aaa:'xzy0' };";
- jerry_value_t parse_result = jerry_parse (code_for_c_format,
- sizeof (code_for_c_format) - 1,
- NULL);
+ jerry_value_t parse_result = jerry_parse (code_for_c_format, sizeof (code_for_c_format) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parse_result));
- jerry_value_t generate_result = jerry_generate_snapshot (parse_result,
- 0,
- literal_snapshot_buffer,
- SNAPSHOT_BUFFER_SIZE);
+ jerry_value_t generate_result =
+ jerry_generate_snapshot (parse_result, 0, literal_snapshot_buffer, SNAPSHOT_BUFFER_SIZE);
jerry_release_value (parse_result);
TEST_ASSERT (!jerry_value_is_error (generate_result));
@@ -455,8 +400,7 @@ main (void)
true);
TEST_ASSERT (lit_c_buf_sz == 239);
- static const char *expected_c_format = (
- "jerry_length_t literal_count = 5;\n\n"
+ static const char *expected_c_format = ("jerry_length_t literal_count = 5;\n\n"
"jerry_char_t *literals[5] =\n"
"{\n"
" \"Bb\",\n"
@@ -472,8 +416,7 @@ main (void)
" 3 /* aaa */,\n"
" 4 /* xzy0 */,\n"
" 8 /* fo\" o\n \\ */\n"
- "};\n"
- );
+ "};\n");
TEST_ASSERT (!strncmp ((char *) literal_buffer_c, expected_c_format, lit_c_buf_sz));
@@ -485,9 +428,8 @@ main (void)
LITERAL_BUFFER_SIZE,
false);
TEST_ASSERT (lit_list_buf_sz == 34);
- TEST_ASSERT (!strncmp ((char *) literal_buffer_list,
- "2 Bb\n2 aa\n3 aaa\n4 xzy0\n8 fo\" o\n \\\n",
- lit_list_buf_sz));
+ TEST_ASSERT (
+ !strncmp ((char *) literal_buffer_list, "2 Bb\n2 aa\n3 aaa\n4 xzy0\n8 fo\" o\n \\\n", lit_list_buf_sz));
jerry_cleanup ();
}
diff --git a/tests/unit-core/test-source-info.c b/tests/unit-core/test-source-info.c
index 2e578aa2..0401eccd 100644
--- a/tests/unit-core/test-source-info.c
+++ b/tests/unit-core/test-source-info.c
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+#include "config.h"
#include "test-common.h"
static void
@@ -106,8 +106,8 @@ main (void)
value = jerry_eval ((const jerry_char_t *) source_p, strlen (source_p), 0);
source_info_p = jerry_get_source_info (value);
TEST_ASSERT (source_info_p != NULL);
- TEST_ASSERT (source_info_p->enabled_fields == (JERRY_SOURCE_INFO_HAS_SOURCE_CODE
- | JERRY_SOURCE_INFO_HAS_SOURCE_RANGE));
+ TEST_ASSERT (source_info_p->enabled_fields
+ == (JERRY_SOURCE_INFO_HAS_SOURCE_CODE | JERRY_SOURCE_INFO_HAS_SOURCE_RANGE));
compare_string (source_info_p->source_code, source_p);
TEST_ASSERT (jerry_value_is_undefined (source_info_p->function_arguments));
TEST_ASSERT (source_info_p->source_range_start == 2);
@@ -120,8 +120,8 @@ main (void)
value = jerry_eval ((const jerry_char_t *) source_p, strlen (source_p), 0);
source_info_p = jerry_get_source_info (value);
TEST_ASSERT (source_info_p != NULL);
- TEST_ASSERT (source_info_p->enabled_fields == (JERRY_SOURCE_INFO_HAS_SOURCE_CODE
- | JERRY_SOURCE_INFO_HAS_FUNCTION_ARGUMENTS));
+ TEST_ASSERT (source_info_p->enabled_fields
+ == (JERRY_SOURCE_INFO_HAS_SOURCE_CODE | JERRY_SOURCE_INFO_HAS_FUNCTION_ARGUMENTS));
compare_string (source_info_p->source_code, "return 0;");
compare_string (source_info_p->function_arguments, "a,b");
TEST_ASSERT (source_info_p->source_range_start == 0);
@@ -134,8 +134,8 @@ main (void)
value = jerry_eval ((const jerry_char_t *) source_p, strlen (source_p), 0);
source_info_p = jerry_get_source_info (value);
TEST_ASSERT (source_info_p != NULL);
- TEST_ASSERT (source_info_p->enabled_fields == (JERRY_SOURCE_INFO_HAS_SOURCE_CODE
- | JERRY_SOURCE_INFO_HAS_SOURCE_RANGE));
+ TEST_ASSERT (source_info_p->enabled_fields
+ == (JERRY_SOURCE_INFO_HAS_SOURCE_CODE | JERRY_SOURCE_INFO_HAS_SOURCE_RANGE));
compare_string (source_info_p->source_code, "a = ( function() { } )");
TEST_ASSERT (jerry_value_is_undefined (source_info_p->function_arguments));
TEST_ASSERT (source_info_p->source_range_start == 6);
@@ -148,8 +148,8 @@ main (void)
value = jerry_eval ((const jerry_char_t *) source_p, strlen (source_p), 0);
source_info_p = jerry_get_source_info (value);
TEST_ASSERT (source_info_p != NULL);
- TEST_ASSERT (source_info_p->enabled_fields == (JERRY_SOURCE_INFO_HAS_SOURCE_CODE
- | JERRY_SOURCE_INFO_HAS_SOURCE_RANGE));
+ TEST_ASSERT (source_info_p->enabled_fields
+ == (JERRY_SOURCE_INFO_HAS_SOURCE_CODE | JERRY_SOURCE_INFO_HAS_SOURCE_RANGE));
compare_string (source_info_p->source_code, source_p);
TEST_ASSERT (jerry_value_is_undefined (source_info_p->function_arguments));
TEST_ASSERT (source_info_p->source_range_start == 1);
diff --git a/tests/unit-core/test-string-to-number.c b/tests/unit-core/test-string-to-number.c
index fd16102e..09927534 100644
--- a/tests/unit-core/test-string-to-number.c
+++ b/tests/unit-core/test-string-to-number.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
+#include "jerryscript.h"
+
#include "ecma-globals.h"
#include "ecma-helpers.h"
-#include "jerryscript.h"
#include "test-common.h"
@@ -27,59 +28,27 @@ main (void)
{
TEST_INIT ();
- const jerry_char_t *strings[] =
- {
- (const jerry_char_t *) "1",
- (const jerry_char_t *) "0.5",
- (const jerry_char_t *) "12345",
- (const jerry_char_t *) "1e-45",
- (const jerry_char_t *) "-2.5e+38",
- (const jerry_char_t *) "-2.5e38",
- (const jerry_char_t *) "- 2.5e+38",
- (const jerry_char_t *) "-2 .5e+38",
- (const jerry_char_t *) "-2. 5e+38",
- (const jerry_char_t *) "-2.5e+ 38",
- (const jerry_char_t *) "-2.5 e+38",
- (const jerry_char_t *) "-2.5e +38",
- (const jerry_char_t *) "NaN",
- (const jerry_char_t *) "abc",
- (const jerry_char_t *) " Infinity ",
- (const jerry_char_t *) "-Infinity",
- (const jerry_char_t *) "0",
- (const jerry_char_t *) "0",
+ const jerry_char_t *strings[] = {
+ (const jerry_char_t *) "1", (const jerry_char_t *) "0.5", (const jerry_char_t *) "12345",
+ (const jerry_char_t *) "1e-45", (const jerry_char_t *) "-2.5e+38", (const jerry_char_t *) "-2.5e38",
+ (const jerry_char_t *) "- 2.5e+38", (const jerry_char_t *) "-2 .5e+38", (const jerry_char_t *) "-2. 5e+38",
+ (const jerry_char_t *) "-2.5e+ 38", (const jerry_char_t *) "-2.5 e+38", (const jerry_char_t *) "-2.5e +38",
+ (const jerry_char_t *) "NaN", (const jerry_char_t *) "abc", (const jerry_char_t *) " Infinity ",
+ (const jerry_char_t *) "-Infinity", (const jerry_char_t *) "0", (const jerry_char_t *) "0",
};
- const ecma_number_t nums[] =
- {
- (ecma_number_t) 1.0,
- (ecma_number_t) 0.5,
- (ecma_number_t) 12345.0,
- (ecma_number_t) 1.0e-45,
- (ecma_number_t) -2.5e+38,
- (ecma_number_t) -2.5e+38,
- (ecma_number_t) NAN,
- (ecma_number_t) NAN,
- (ecma_number_t) NAN,
- (ecma_number_t) NAN,
- (ecma_number_t) NAN,
- (ecma_number_t) NAN,
- (ecma_number_t) NAN,
- (ecma_number_t) NAN,
- (ecma_number_t) INFINITY,
- (ecma_number_t) -INFINITY,
- (ecma_number_t) +0.0,
- (ecma_number_t) -0.0
- };
+ const ecma_number_t nums[] = { (ecma_number_t) 1.0, (ecma_number_t) 0.5, (ecma_number_t) 12345.0,
+ (ecma_number_t) 1.0e-45, (ecma_number_t) -2.5e+38, (ecma_number_t) -2.5e+38,
+ (ecma_number_t) NAN, (ecma_number_t) NAN, (ecma_number_t) NAN,
+ (ecma_number_t) NAN, (ecma_number_t) NAN, (ecma_number_t) NAN,
+ (ecma_number_t) NAN, (ecma_number_t) NAN, (ecma_number_t) INFINITY,
+ (ecma_number_t) -INFINITY, (ecma_number_t) + 0.0, (ecma_number_t) -0.0 };
- for (uint32_t i = 0;
- i < sizeof (nums) / sizeof (nums[0]);
- i++)
+ for (uint32_t i = 0; i < sizeof (nums) / sizeof (nums[0]); i++)
{
ecma_number_t num = ecma_utf8_string_to_number (strings[i], lit_zt_utf8_string_size (strings[i]), 0);
- if (num != nums[i]
- && (!ecma_number_is_nan (num)
- || !ecma_number_is_nan (nums[i])))
+ if (num != nums[i] && (!ecma_number_is_nan (num) || !ecma_number_is_nan (nums[i])))
{
return 1;
}
diff --git a/tests/unit-core/test-stringbuilder.c b/tests/unit-core/test-stringbuilder.c
index 99a1defb..3eabbbc4 100644
--- a/tests/unit-core/test-stringbuilder.c
+++ b/tests/unit-core/test-stringbuilder.c
@@ -15,9 +15,9 @@
#include "ecma-helpers.h"
#include "ecma-init-finalize.h"
+
#include "lit-char-helpers.h"
#include "lit-strings.h"
-
#include "test-common.h"
int
@@ -158,10 +158,8 @@ main (void)
ecma_string_t *expected_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
for (size_t i = 0; i < count; i++)
{
- expected_p = ecma_append_chars_to_string (expected_p,
- string_data,
- sizeof (string_data) - 1,
- sizeof (string_data) - 1);
+ expected_p =
+ ecma_append_chars_to_string (expected_p, string_data, sizeof (string_data) - 1, sizeof (string_data) - 1);
}
TEST_ASSERT (ecma_compare_ecma_strings (result_p, expected_p));
diff --git a/tests/unit-core/test-strings.c b/tests/unit-core/test-strings.c
index 0f756fe0..275a2fb8 100644
--- a/tests/unit-core/test-strings.c
+++ b/tests/unit-core/test-strings.c
@@ -14,9 +14,9 @@
*/
#include "ecma-helpers.h"
-#include "lit-strings.h"
#include "ecma-init-finalize.h"
+#include "lit-strings.h"
#include "test-common.h"
/* Iterations count. */
@@ -26,7 +26,7 @@
#define test_subiters (128)
/* Max bytes in string. */
-#define max_bytes_in_string (65 * 1024)
+#define max_bytes_in_string (65 * 1024)
#define max_code_units_in_string (max_bytes_in_string)
typedef enum
@@ -38,8 +38,7 @@ typedef enum
} utf8_char_size;
static lit_utf8_size_t
-generate_cesu8_char (utf8_char_size char_size,
- lit_utf8_byte_t *buf)
+generate_cesu8_char (utf8_char_size char_size, lit_utf8_byte_t *buf)
{
TEST_ASSERT (char_size >= 0 && char_size <= LIT_CESU8_MAX_BYTES_IN_CODE_UNIT);
lit_code_point_t code_point = (lit_code_point_t) rand ();
@@ -50,21 +49,20 @@ generate_cesu8_char (utf8_char_size char_size,
}
else if (char_size == 2)
{
- code_point = LIT_UTF8_2_BYTE_CODE_POINT_MIN + code_point % (LIT_UTF8_2_BYTE_CODE_POINT_MAX -
- LIT_UTF8_2_BYTE_CODE_POINT_MIN);
+ code_point =
+ LIT_UTF8_2_BYTE_CODE_POINT_MIN + code_point % (LIT_UTF8_2_BYTE_CODE_POINT_MAX - LIT_UTF8_2_BYTE_CODE_POINT_MIN);
}
else if (char_size == 3)
{
- code_point = LIT_UTF8_3_BYTE_CODE_POINT_MIN + code_point % (LIT_UTF8_3_BYTE_CODE_POINT_MAX -
- LIT_UTF8_3_BYTE_CODE_POINT_MIN);
+ code_point =
+ LIT_UTF8_3_BYTE_CODE_POINT_MIN + code_point % (LIT_UTF8_3_BYTE_CODE_POINT_MAX - LIT_UTF8_3_BYTE_CODE_POINT_MIN);
}
else
{
code_point %= LIT_UTF8_3_BYTE_CODE_POINT_MAX;
}
- if (code_point >= LIT_UTF16_HIGH_SURROGATE_MIN
- && code_point <= LIT_UTF16_LOW_SURROGATE_MAX)
+ if (code_point >= LIT_UTF16_HIGH_SURROGATE_MIN && code_point <= LIT_UTF16_LOW_SURROGATE_MAX)
{
code_point = LIT_UTF16_HIGH_SURROGATE_MIN - 1;
}
@@ -73,17 +71,15 @@ generate_cesu8_char (utf8_char_size char_size,
} /* generate_cesu8_char */
static lit_utf8_size_t
-generate_cesu8_string (lit_utf8_byte_t *buf_p,
- lit_utf8_size_t buf_size)
+generate_cesu8_string (lit_utf8_byte_t *buf_p, lit_utf8_size_t buf_size)
{
lit_utf8_size_t length = 0;
lit_utf8_size_t size = 0;
- while (size < buf_size)
+ while (size < buf_size)
{
- const utf8_char_size char_size = (((buf_size - size) > LIT_CESU8_MAX_BYTES_IN_CODE_UNIT)
- ? CESU8_ANY_SIZE
- : (utf8_char_size) (buf_size - size));
+ const utf8_char_size char_size =
+ (((buf_size - size) > LIT_CESU8_MAX_BYTES_IN_CODE_UNIT) ? CESU8_ANY_SIZE : (utf8_char_size) (buf_size - size));
lit_utf8_size_t bytes_generated = generate_cesu8_char (char_size, buf_p);
@@ -182,19 +178,19 @@ main (void)
}
/* Overlong-encoded code point */
- lit_utf8_byte_t invalid_cesu8_string_1[] = {0xC0, 0x82};
+ lit_utf8_byte_t invalid_cesu8_string_1[] = { 0xC0, 0x82 };
TEST_ASSERT (!lit_is_valid_cesu8_string (invalid_cesu8_string_1, sizeof (invalid_cesu8_string_1)));
/* Overlong-encoded code point */
- lit_utf8_byte_t invalid_cesu8_string_2[] = {0xE0, 0x80, 0x81};
+ lit_utf8_byte_t invalid_cesu8_string_2[] = { 0xE0, 0x80, 0x81 };
TEST_ASSERT (!lit_is_valid_cesu8_string (invalid_cesu8_string_2, sizeof (invalid_cesu8_string_2)));
/* Pair of surrogates: 0xD901 0xDFF0 which encode Unicode character 0x507F0 */
- lit_utf8_byte_t invalid_cesu8_string_3[] = {0xED, 0xA4, 0x81, 0xED, 0xBF, 0xB0};
+ lit_utf8_byte_t invalid_cesu8_string_3[] = { 0xED, 0xA4, 0x81, 0xED, 0xBF, 0xB0 };
TEST_ASSERT (lit_is_valid_cesu8_string (invalid_cesu8_string_3, sizeof (invalid_cesu8_string_3)));
/* Isolated high surrogate 0xD901 */
- lit_utf8_byte_t valid_utf8_string_1[] = {0xED, 0xA4, 0x81};
+ lit_utf8_byte_t valid_utf8_string_1[] = { 0xED, 0xA4, 0x81 };
TEST_ASSERT (lit_is_valid_cesu8_string (valid_utf8_string_1, sizeof (valid_utf8_string_1)));
lit_utf8_byte_t res_buf[3];
@@ -216,39 +212,39 @@ main (void)
TEST_ASSERT (res_buf[2] == 0xBF);
/* Ascii string */
- lit_utf8_byte_t utf8_string_ascii[] = {'G','o','o','d','b','y','e'};
+ lit_utf8_byte_t utf8_string_ascii[] = { 'G', 'o', 'o', 'd', 'b', 'y', 'e' };
TEST_ASSERT (lit_is_valid_utf8_string (utf8_string_ascii, sizeof (utf8_string_ascii), true));
/* Control character */
- lit_utf8_byte_t utf8_string_control[] = {0x00};
+ lit_utf8_byte_t utf8_string_control[] = { 0x00 };
TEST_ASSERT (lit_is_valid_utf8_string (utf8_string_control, sizeof (utf8_string_control), true));
/* 3 byte characters */
- lit_utf8_byte_t utf8_string_3byte[] = {0xe4, 0xbd, 0xa0, 0xe5, 0xa5, 0xbd, 0xe4, 0xb8, 0x96, 0xe7, 0x95, 0x8c};
+ lit_utf8_byte_t utf8_string_3byte[] = { 0xe4, 0xbd, 0xa0, 0xe5, 0xa5, 0xbd, 0xe4, 0xb8, 0x96, 0xe7, 0x95, 0x8c };
TEST_ASSERT (lit_is_valid_utf8_string (utf8_string_3byte, sizeof (utf8_string_3byte), true));
/* 4 byte characters */
- lit_utf8_byte_t utf8_string_4byte[] = {0xf0, 0x90, 0x80, 0x80, 0xf0, 0x9f, 0xa7, 0xbf};
+ lit_utf8_byte_t utf8_string_4byte[] = { 0xf0, 0x90, 0x80, 0x80, 0xf0, 0x9f, 0xa7, 0xbf };
TEST_ASSERT (lit_is_valid_utf8_string (utf8_string_4byte, sizeof (utf8_string_4byte), true));
/* Invalid continuation byte */
- lit_utf8_byte_t utf8_string_invalid[] = {0xa0};
+ lit_utf8_byte_t utf8_string_invalid[] = { 0xa0 };
TEST_ASSERT (!lit_is_valid_utf8_string (utf8_string_invalid, sizeof (utf8_string_invalid), true));
/* Isolated high surrogate */
- lit_utf8_byte_t utf8_string_high[] = {0xed, 0xa0, 0x80};
+ lit_utf8_byte_t utf8_string_high[] = { 0xed, 0xa0, 0x80 };
TEST_ASSERT (lit_is_valid_utf8_string (utf8_string_high, sizeof (utf8_string_high), true));
/* Isolated low surrogate */
- lit_utf8_byte_t utf8_string_low[] = {0xed, 0xbf, 0xbf};
+ lit_utf8_byte_t utf8_string_low[] = { 0xed, 0xbf, 0xbf };
TEST_ASSERT (lit_is_valid_utf8_string (utf8_string_low, sizeof (utf8_string_low), true));
/* Correct pair of surrogates in strict*/
- lit_utf8_byte_t utf8_string_surrogates_strict[] = {0xed, 0xa0, 0x80, 0xed, 0xbf, 0xbf};
+ lit_utf8_byte_t utf8_string_surrogates_strict[] = { 0xed, 0xa0, 0x80, 0xed, 0xbf, 0xbf };
TEST_ASSERT (!lit_is_valid_utf8_string (utf8_string_surrogates_strict, sizeof (utf8_string_surrogates_strict), true));
/* Correct pair of surrogates*/
- lit_utf8_byte_t utf8_string_surrogates[] = {0xed, 0xa0, 0x80, 0xed, 0xbf, 0xbf};
+ lit_utf8_byte_t utf8_string_surrogates[] = { 0xed, 0xa0, 0x80, 0xed, 0xbf, 0xbf };
TEST_ASSERT (lit_is_valid_utf8_string (utf8_string_surrogates, sizeof (utf8_string_surrogates), false));
ecma_finalize ();
diff --git a/tests/unit-core/test-symbol.c b/tests/unit-core/test-symbol.c
index 500c2a4e..b6eae332 100644
--- a/tests/unit-core/test-symbol.c
+++ b/tests/unit-core/test-symbol.c
@@ -13,9 +13,10 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
#include "jerryscript-port-default.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
+
#include "test-common.h"
/* foo string */
@@ -107,10 +108,8 @@ main (void)
prop_desc = jerry_property_descriptor_create ();
jerry_value_t value_3 = jerry_create_string (STRING_BAR);
- prop_desc.flags |= JERRY_PROP_IS_VALUE_DEFINED
- | JERRY_PROP_IS_WRITABLE_DEFINED
- | JERRY_PROP_IS_ENUMERABLE_DEFINED
- | JERRY_PROP_IS_CONFIGURABLE_DEFINED;
+ prop_desc.flags |= JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED | JERRY_PROP_IS_ENUMERABLE_DEFINED
+ | JERRY_PROP_IS_CONFIGURABLE_DEFINED;
prop_desc.value = jerry_acquire_value (value_3);
TEST_ASSERT (jerry_value_is_true (jerry_define_own_property (object, symbol_2, &prop_desc)));
jerry_property_descriptor_free (&prop_desc);
@@ -216,37 +215,25 @@ main (void)
jerry_release_value (null_value);
const jerry_char_t obj_src[] = ""
- "({"
- " [Symbol.asyncIterator]: 1,"
- " [Symbol.hasInstance]: 2,"
- " [Symbol.isConcatSpreadable]: 3,"
- " [Symbol.iterator]: 4,"
- " [Symbol.match]: 5,"
- " [Symbol.replace]: 6,"
- " [Symbol.search]: 7,"
- " [Symbol.species]: 8,"
- " [Symbol.split]: 9,"
- " [Symbol.toPrimitive]: 10,"
- " [Symbol.toStringTag]: 11,"
- " [Symbol.unscopables]: 12,"
- " [Symbol.matchAll]: 13,"
- "})";
-
- const char *symbols[] =
- {
- "asyncIterator",
- "hasInstance",
- "isConcatSpreadable",
- "iterator",
- "match",
- "replace",
- "search",
- "species",
- "split",
- "toPrimitive",
- "toStringTag",
- "unscopables",
- "matchAll",
+ "({"
+ " [Symbol.asyncIterator]: 1,"
+ " [Symbol.hasInstance]: 2,"
+ " [Symbol.isConcatSpreadable]: 3,"
+ " [Symbol.iterator]: 4,"
+ " [Symbol.match]: 5,"
+ " [Symbol.replace]: 6,"
+ " [Symbol.search]: 7,"
+ " [Symbol.species]: 8,"
+ " [Symbol.split]: 9,"
+ " [Symbol.toPrimitive]: 10,"
+ " [Symbol.toStringTag]: 11,"
+ " [Symbol.unscopables]: 12,"
+ " [Symbol.matchAll]: 13,"
+ "})";
+
+ const char *symbols[] = {
+ "asyncIterator", "hasInstance", "isConcatSpreadable", "iterator", "match", "replace", "search",
+ "species", "split", "toPrimitive", "toStringTag", "unscopables", "matchAll",
};
jerry_value_t obj = jerry_eval (obj_src, sizeof (obj_src) - 1, JERRY_PARSE_NO_OPTS);
@@ -260,8 +247,7 @@ main (void)
double expected = 1.0;
uint32_t prop_index = 0;
- for (jerry_well_known_symbol_t id = JERRY_SYMBOL_ASYNC_ITERATOR;
- id <= JERRY_SYMBOL_MATCH_ALL;
+ for (jerry_well_known_symbol_t id = JERRY_SYMBOL_ASYNC_ITERATOR; id <= JERRY_SYMBOL_MATCH_ALL;
id++, expected++, prop_index++)
{
jerry_value_t well_known_symbol = jerry_get_well_known_symbol (id);
@@ -270,12 +256,10 @@ main (void)
jerry_value_t current_global_symbol = jerry_get_property (builtin_symbol, prop_str);
jerry_release_value (prop_str);
- jerry_value_t relation = jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL,
- well_known_symbol,
- current_global_symbol);
+ jerry_value_t relation =
+ jerry_binary_operation (JERRY_BIN_OP_STRICT_EQUAL, well_known_symbol, current_global_symbol);
- TEST_ASSERT (jerry_value_is_boolean (relation)
- && jerry_value_is_true (relation));
+ TEST_ASSERT (jerry_value_is_boolean (relation) && jerry_value_is_true (relation));
jerry_release_value (relation);
@@ -303,8 +287,7 @@ main (void)
const jerry_char_t deleter_src[] = "delete Symbol";
jerry_value_t deleter = jerry_eval (deleter_src, sizeof (deleter_src) - 1, JERRY_PARSE_NO_OPTS);
- TEST_ASSERT (jerry_value_is_boolean (deleter)
- && jerry_value_is_true (deleter));
+ TEST_ASSERT (jerry_value_is_boolean (deleter) && jerry_value_is_true (deleter));
jerry_release_value (deleter);
builtin_symbol = jerry_get_property (global_obj, symbol_str);
@@ -314,8 +297,7 @@ main (void)
expected = 1.0;
prop_index = 0;
- for (jerry_well_known_symbol_t id = JERRY_SYMBOL_ASYNC_ITERATOR;
- id <= JERRY_SYMBOL_MATCH_ALL;
+ for (jerry_well_known_symbol_t id = JERRY_SYMBOL_ASYNC_ITERATOR; id <= JERRY_SYMBOL_MATCH_ALL;
id++, expected++, prop_index++)
{
jerry_value_t well_known_symbol = jerry_get_well_known_symbol (id);
diff --git a/tests/unit-core/test-to-integer.c b/tests/unit-core/test-to-integer.c
index e606b2c1..a82b95ed 100644
--- a/tests/unit-core/test-to-integer.c
+++ b/tests/unit-core/test-to-integer.c
@@ -14,14 +14,15 @@
* limitations under the License.
*/
+#include "jerryscript.h"
+
+#include "ecma-conversion.h"
+#include "ecma-exceptions.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
-#include "ecma-conversion.h"
#include "ecma-init-finalize.h"
-#include "ecma-exceptions.h"
-#include "jerryscript.h"
-#include "jcontext.h"
+#include "jcontext.h"
#include "test-common.h"
/**
@@ -66,7 +67,7 @@ main (void)
TEST_ASSERT (num == 0);
/* 4 */
- /* -0 */
+ /* -0 */
ecma_value_t negative_zero = ecma_make_number_value (-0.0f);
result = ecma_op_to_integer (negative_zero, &num);
@@ -76,7 +77,7 @@ main (void)
TEST_ASSERT (!ECMA_IS_VALUE_ERROR (result));
TEST_ASSERT (1.0f / num == ecma_number_make_infinity (true));
- /* +0 */
+ /* +0 */
ecma_value_t positive_zero = ecma_make_number_value (+0.0f);
result = ecma_op_to_integer (positive_zero, &num);
@@ -86,7 +87,7 @@ main (void)
TEST_ASSERT (!ECMA_IS_VALUE_ERROR (result));
TEST_ASSERT (1.0f / num == ecma_number_make_infinity (false));
- /* -infinity */
+ /* -infinity */
ecma_value_t negative_infinity = ecma_make_number_value (ecma_number_make_infinity (true));
result = ecma_op_to_integer (negative_infinity, &num);
@@ -96,7 +97,7 @@ main (void)
TEST_ASSERT (!ECMA_IS_VALUE_ERROR (result));
TEST_ASSERT (num == ecma_number_make_infinity (true));
- /* +infinity */
+ /* +infinity */
ecma_value_t positive_infinity = ecma_make_number_value (ecma_number_make_infinity (false));
result = ecma_op_to_integer (positive_infinity, &num);
diff --git a/tests/unit-core/test-to-length.c b/tests/unit-core/test-to-length.c
index 4b0094cc..fc98dac7 100644
--- a/tests/unit-core/test-to-length.c
+++ b/tests/unit-core/test-to-length.c
@@ -14,14 +14,15 @@
* limitations under the License.
*/
+#include "jerryscript.h"
+
+#include "ecma-conversion.h"
+#include "ecma-exceptions.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
-#include "ecma-conversion.h"
#include "ecma-init-finalize.h"
-#include "ecma-exceptions.h"
-#include "jerryscript.h"
-#include "jcontext.h"
+#include "jcontext.h"
#include "test-common.h"
/**
diff --git a/tests/unit-core/test-to-property-descriptor.c b/tests/unit-core/test-to-property-descriptor.c
index 993eea19..e7c40481 100644
--- a/tests/unit-core/test-to-property-descriptor.c
+++ b/tests/unit-core/test-to-property-descriptor.c
@@ -13,8 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+
+#include "config.h"
#include "test-common.h"
static jerry_value_t
diff --git a/tests/unit-core/test-typedarray.c b/tests/unit-core/test-typedarray.c
index 623d31a5..4f19856f 100644
--- a/tests/unit-core/test-typedarray.c
+++ b/tests/unit-core/test-typedarray.c
@@ -13,12 +13,13 @@
* limitations under the License.
*/
-#include "jerryscript.h"
-#include "jerryscript-port.h"
+#include <stdio.h>
+
#include "jerryscript-port-default.h"
-#include "test-common.h"
+#include "jerryscript-port.h"
+#include "jerryscript.h"
-#include <stdio.h>
+#include "test-common.h"
/**
* Type to describe test cases.
@@ -62,8 +63,7 @@ assert_handler (const jerry_call_info_t *call_info_p, /**< call information */
}
else
{
- if (args_cnt > 1
- && jerry_value_is_string (args_p[1]))
+ if (args_cnt > 1 && jerry_value_is_string (args_p[1]))
{
jerry_length_t utf8_sz = jerry_get_string_size (args_p[1]);
TEST_ASSERT (utf8_sz <= 127); /* 127 is the expected max assert fail message size. */
@@ -135,8 +135,8 @@ test_typedarray_queries (test_entry_t test_entries[]) /**< test cases */
/* Create TypedArray via api call */
{
- jerry_value_t typedarray = jerry_create_typedarray (test_entries[i].typedarray_type,
- test_entries[i].element_count);
+ jerry_value_t typedarray =
+ jerry_create_typedarray (test_entries[i].typedarray_type, test_entries[i].element_count);
test_typedarray_info (typedarray,
test_entries[i].typedarray_type,
test_entries[i].element_count,
@@ -151,12 +151,12 @@ test_typedarray_queries (test_entry_t test_entries[]) /**< test cases */
/**
* Test value at given position in the buffer based on TypedArray type.
*/
-static
-void test_buffer_value (uint64_t value, /**< value to test for */
- const void *buffer, /**< buffer to read value from */
- uint32_t start_offset, /**< start offset of the value */
- jerry_typedarray_type_t typedarray_type, /**< type of TypedArray */
- uint32_t bytes_per_element) /**< bytes per element for the given type */
+static void
+test_buffer_value (uint64_t value, /**< value to test for */
+ const void *buffer, /**< buffer to read value from */
+ uint32_t start_offset, /**< start offset of the value */
+ jerry_typedarray_type_t typedarray_type, /**< type of TypedArray */
+ uint32_t bytes_per_element) /**< bytes per element for the given type */
{
uint32_t offset = start_offset / bytes_per_element;
@@ -164,16 +164,36 @@ void test_buffer_value (uint64_t value, /**< value to test for */
switch (typedarray_type)
{
- case JERRY_TYPEDARRAY_UINT8: TEST_VALUE_AT (uint8_t, buffer, offset, value); break;
- case JERRY_TYPEDARRAY_INT8: TEST_VALUE_AT (int8_t, buffer, offset, value); break;
- case JERRY_TYPEDARRAY_UINT16: TEST_VALUE_AT (uint16_t, buffer, offset, value); break;
- case JERRY_TYPEDARRAY_INT16: TEST_VALUE_AT (int16_t, buffer, offset, value); break;
- case JERRY_TYPEDARRAY_UINT32: TEST_VALUE_AT (uint32_t, buffer, offset, value); break;
- case JERRY_TYPEDARRAY_INT32: TEST_VALUE_AT (int32_t, buffer, offset, value); break;
- case JERRY_TYPEDARRAY_FLOAT32: TEST_VALUE_AT (float, buffer, offset, value); break;
- case JERRY_TYPEDARRAY_FLOAT64: TEST_VALUE_AT (double, buffer, offset, value); break;
- case JERRY_TYPEDARRAY_BIGINT64: TEST_VALUE_AT (int64_t, buffer, offset, value); break;
- case JERRY_TYPEDARRAY_BIGUINT64: TEST_VALUE_AT (uint64_t, buffer, offset, value); break;
+ case JERRY_TYPEDARRAY_UINT8:
+ TEST_VALUE_AT (uint8_t, buffer, offset, value);
+ break;
+ case JERRY_TYPEDARRAY_INT8:
+ TEST_VALUE_AT (int8_t, buffer, offset, value);
+ break;
+ case JERRY_TYPEDARRAY_UINT16:
+ TEST_VALUE_AT (uint16_t, buffer, offset, value);
+ break;
+ case JERRY_TYPEDARRAY_INT16:
+ TEST_VALUE_AT (int16_t, buffer, offset, value);
+ break;
+ case JERRY_TYPEDARRAY_UINT32:
+ TEST_VALUE_AT (uint32_t, buffer, offset, value);
+ break;
+ case JERRY_TYPEDARRAY_INT32:
+ TEST_VALUE_AT (int32_t, buffer, offset, value);
+ break;
+ case JERRY_TYPEDARRAY_FLOAT32:
+ TEST_VALUE_AT (float, buffer, offset, value);
+ break;
+ case JERRY_TYPEDARRAY_FLOAT64:
+ TEST_VALUE_AT (double, buffer, offset, value);
+ break;
+ case JERRY_TYPEDARRAY_BIGINT64:
+ TEST_VALUE_AT (int64_t, buffer, offset, value);
+ break;
+ case JERRY_TYPEDARRAY_BIGUINT64:
+ TEST_VALUE_AT (uint64_t, buffer, offset, value);
+ break;
case JERRY_TYPEDARRAY_UINT8CLAMPED:
{
@@ -190,9 +210,12 @@ void test_buffer_value (uint64_t value, /**< value to test for */
expected = 0;
}
- TEST_VALUE_AT (uint8_t, buffer, offset, expected); break;
+ TEST_VALUE_AT (uint8_t, buffer, offset, expected);
+ break;
}
- default: TEST_ASSERT (false); break;
+ default:
+ TEST_ASSERT (false);
+ break;
}
#undef TEST_VALUE_AT
@@ -245,20 +268,15 @@ test_typedarray_complex_creation (test_entry_t test_entries[], /**< test cases *
register_js_value ("array", typedarray);
- const jerry_char_t test_exptected_src[] = TEST_STRING_LITERAL (
- "assert (array.length == expected_length,"
- " 'expected length: ' + expected_length + ' got: ' + array.length);"
- "assert (array.byteOffset == expected_offset);"
- );
- jerry_value_t result = jerry_eval (test_exptected_src,
- sizeof (test_exptected_src) - 1,
- JERRY_PARSE_STRICT_MODE);
+ const jerry_char_t test_exptected_src[] =
+ TEST_STRING_LITERAL ("assert (array.length == expected_length,"
+ " 'expected length: ' + expected_length + ' got: ' + array.length);"
+ "assert (array.byteOffset == expected_offset);");
+ jerry_value_t result = jerry_eval (test_exptected_src, sizeof (test_exptected_src) - 1, JERRY_PARSE_STRICT_MODE);
TEST_ASSERT (!jerry_value_is_error (result));
jerry_release_value (result);
- const jerry_char_t set_element_src[] = TEST_STRING_LITERAL (
- "array[0] = 0x11223344n"
- );
+ const jerry_char_t set_element_src[] = TEST_STRING_LITERAL ("array[0] = 0x11223344n");
/* crop the last 'n' character */
size_t src_length = sizeof (set_element_src) - 2;
@@ -303,13 +321,14 @@ test_typedarray_complex_creation (test_entry_t test_entries[], /**< test cases *
/**
* Test get/set/delete property by index.
*/
-static void test_property_by_index (test_entry_t test_entries[])
+static void
+test_property_by_index (test_entry_t test_entries[])
{
- int test_int_numbers[5] = {-5, -70, 13, 0, 56};
- double test_double_numbers[5] = {-83.153, -35.15, 0, 13.1, 89.8975};
- uint8_t test_uint_numbers[5] = {83, 15, 36, 0, 43};
- uint64_t test_uint64_numbers[5] = {83, 0, 1, UINT32_MAX, UINT64_MAX};
- int64_t test_int64_numbers[5] = {INT64_MAX, INT64_MIN, 0, INT32_MAX, INT32_MIN};
+ int test_int_numbers[5] = { -5, -70, 13, 0, 56 };
+ double test_double_numbers[5] = { -83.153, -35.15, 0, 13.1, 89.8975 };
+ uint8_t test_uint_numbers[5] = { 83, 15, 36, 0, 43 };
+ uint64_t test_uint64_numbers[5] = { 83, 0, 1, UINT32_MAX, UINT64_MAX };
+ int64_t test_int64_numbers[5] = { INT64_MAX, INT64_MIN, 0, INT32_MAX, INT32_MIN };
for (uint32_t i = 0; test_entries[i].constructor_name != NULL; i++)
{
@@ -486,19 +505,10 @@ static void test_property_by_index (test_entry_t test_entries[])
static void
test_detached_arraybuffer (void)
{
- static jerry_typedarray_type_t types[] =
- {
- JERRY_TYPEDARRAY_UINT8,
- JERRY_TYPEDARRAY_UINT8CLAMPED,
- JERRY_TYPEDARRAY_INT8,
- JERRY_TYPEDARRAY_UINT16,
- JERRY_TYPEDARRAY_INT16,
- JERRY_TYPEDARRAY_UINT32,
- JERRY_TYPEDARRAY_INT32,
- JERRY_TYPEDARRAY_FLOAT32,
- JERRY_TYPEDARRAY_FLOAT64,
- JERRY_TYPEDARRAY_BIGINT64,
- JERRY_TYPEDARRAY_BIGUINT64,
+ static jerry_typedarray_type_t types[] = {
+ JERRY_TYPEDARRAY_UINT8, JERRY_TYPEDARRAY_UINT8CLAMPED, JERRY_TYPEDARRAY_INT8, JERRY_TYPEDARRAY_UINT16,
+ JERRY_TYPEDARRAY_INT16, JERRY_TYPEDARRAY_UINT32, JERRY_TYPEDARRAY_INT32, JERRY_TYPEDARRAY_FLOAT32,
+ JERRY_TYPEDARRAY_FLOAT64, JERRY_TYPEDARRAY_BIGINT64, JERRY_TYPEDARRAY_BIGUINT64,
};
/* Creating an TypedArray for a detached array buffer with a given length/offset is invalid */
@@ -576,24 +586,22 @@ main (void)
register_js_value ("assert", function_val);
jerry_release_value (function_val);
- test_entry_t test_entries[] =
- {
-#define TEST_ENTRY(TYPE, CONSTRUCTOR, COUNT, BYTES_PER_ELEMENT) \
- { TYPE, CONSTRUCTOR, COUNT, BYTES_PER_ELEMENT }
+ test_entry_t test_entries[] = {
+#define TEST_ENTRY(TYPE, CONSTRUCTOR, COUNT, BYTES_PER_ELEMENT) { TYPE, CONSTRUCTOR, COUNT, BYTES_PER_ELEMENT }
- TEST_ENTRY (JERRY_TYPEDARRAY_UINT8, "Uint8Array", 12, 1),
+ TEST_ENTRY (JERRY_TYPEDARRAY_UINT8, "Uint8Array", 12, 1),
TEST_ENTRY (JERRY_TYPEDARRAY_UINT8CLAMPED, "Uint8ClampedArray", 12, 1),
- TEST_ENTRY (JERRY_TYPEDARRAY_INT8, "Int8Array", 12, 1),
- TEST_ENTRY (JERRY_TYPEDARRAY_UINT16, "Uint16Array", 12, 2),
- TEST_ENTRY (JERRY_TYPEDARRAY_INT16, "Int16Array", 12, 2),
- TEST_ENTRY (JERRY_TYPEDARRAY_UINT16, "Uint16Array", 12, 2),
- TEST_ENTRY (JERRY_TYPEDARRAY_INT32, "Int32Array", 12, 4),
- TEST_ENTRY (JERRY_TYPEDARRAY_UINT32, "Uint32Array", 12, 4),
- TEST_ENTRY (JERRY_TYPEDARRAY_FLOAT32, "Float32Array", 12, 4),
- /* TODO: add check if the float64 is supported */
- TEST_ENTRY (JERRY_TYPEDARRAY_FLOAT64, "Float64Array", 12, 8),
- TEST_ENTRY (JERRY_TYPEDARRAY_BIGINT64, "BigInt64Array", 12, 8),
- TEST_ENTRY (JERRY_TYPEDARRAY_BIGUINT64, "BigUint64Array", 12, 8),
+ TEST_ENTRY (JERRY_TYPEDARRAY_INT8, "Int8Array", 12, 1),
+ TEST_ENTRY (JERRY_TYPEDARRAY_UINT16, "Uint16Array", 12, 2),
+ TEST_ENTRY (JERRY_TYPEDARRAY_INT16, "Int16Array", 12, 2),
+ TEST_ENTRY (JERRY_TYPEDARRAY_UINT16, "Uint16Array", 12, 2),
+ TEST_ENTRY (JERRY_TYPEDARRAY_INT32, "Int32Array", 12, 4),
+ TEST_ENTRY (JERRY_TYPEDARRAY_UINT32, "Uint32Array", 12, 4),
+ TEST_ENTRY (JERRY_TYPEDARRAY_FLOAT32, "Float32Array", 12, 4),
+ /* TODO: add check if the float64 is supported */
+ TEST_ENTRY (JERRY_TYPEDARRAY_FLOAT64, "Float64Array", 12, 8),
+ TEST_ENTRY (JERRY_TYPEDARRAY_BIGINT64, "BigInt64Array", 12, 8),
+ TEST_ENTRY (JERRY_TYPEDARRAY_BIGUINT64, "BigUint64Array", 12, 8),
TEST_ENTRY (JERRY_TYPEDARRAY_INVALID, NULL, 0, 0)
#undef TEST_ENTRY
@@ -639,11 +647,8 @@ main (void)
"{"
" assert (array[i] == expected_value);"
" array[i] = i;"
- "};"
- );
- jerry_value_t result = jerry_eval (eval_src,
- sizeof (eval_src) - 1,
- JERRY_PARSE_STRICT_MODE);
+ "};");
+ jerry_value_t result = jerry_eval (eval_src, sizeof (eval_src) - 1, JERRY_PARSE_STRICT_MODE);
TEST_ASSERT (!jerry_value_is_error (result));
jerry_release_value (result);
@@ -678,8 +683,7 @@ main (void)
/* test invalid things */
{
- jerry_value_t values[] =
- {
+ jerry_value_t values[] = {
jerry_create_number (11),
jerry_create_boolean (false),
jerry_create_string ((const jerry_char_t *) "test"),
diff --git a/tests/unit-core/test-unicode.c b/tests/unit-core/test-unicode.c
index 78b1ddad..86a4db84 100644
--- a/tests/unit-core/test-unicode.c
+++ b/tests/unit-core/test-unicode.c
@@ -14,14 +14,13 @@
*/
#include "jerryscript.h"
+
#include "test-common.h"
static bool
test_syntax_error (char *script_p) /**< script */
{
- jerry_value_t parse_result = jerry_parse ((const jerry_char_t *) script_p,
- strlen (script_p),
- NULL);
+ jerry_value_t parse_result = jerry_parse ((const jerry_char_t *) script_p, strlen (script_p), NULL);
bool result = false;
diff --git a/tests/unit-core/test-vm-exec-stop.c b/tests/unit-core/test-vm-exec-stop.c
index 7704b4f8..083095e3 100644
--- a/tests/unit-core/test-vm-exec-stop.c
+++ b/tests/unit-core/test-vm-exec-stop.c
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+#include "config.h"
#include "test-common.h"
static jerry_value_t
@@ -50,9 +50,7 @@ main (void)
jerry_set_vm_exec_stop_callback (vm_exec_stop_callback, &countdown, 16);
const jerry_char_t inf_loop_code_src1[] = "while(true) {}";
- jerry_value_t parsed_code_val = jerry_parse (inf_loop_code_src1,
- sizeof (inf_loop_code_src1) - 1,
- NULL);
+ jerry_value_t parsed_code_val = jerry_parse (inf_loop_code_src1, sizeof (inf_loop_code_src1) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
jerry_value_t res = jerry_run (parsed_code_val);
@@ -69,14 +67,10 @@ main (void)
/* We keep the callback function, only the countdown is reset. */
countdown = 6;
- const jerry_char_t inf_loop_code_src2[] = TEST_STRING_LITERAL (
- "function f() { while (true) ; }\n"
- "try { f(); } catch(e) {}"
- );
+ const jerry_char_t inf_loop_code_src2[] = TEST_STRING_LITERAL ("function f() { while (true) ; }\n"
+ "try { f(); } catch(e) {}");
- parsed_code_val = jerry_parse (inf_loop_code_src2,
- sizeof (inf_loop_code_src2) - 1,
- NULL);
+ parsed_code_val = jerry_parse (inf_loop_code_src2, sizeof (inf_loop_code_src2) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
res = jerry_run (parsed_code_val);
diff --git a/tests/unit-core/test-vm-throw.c b/tests/unit-core/test-vm-throw.c
index dd781b62..ba74da50 100644
--- a/tests/unit-core/test-vm-throw.c
+++ b/tests/unit-core/test-vm-throw.c
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-#include "config.h"
#include "jerryscript.h"
+#include "config.h"
#include "test-common.h"
static int mode = 0;
@@ -147,8 +147,7 @@ main (void)
mode = 0;
counter = 0;
- do_eval (TEST_STRING_LITERAL ("throw -5.6"),
- true);
+ do_eval (TEST_STRING_LITERAL ("throw -5.6"), true);
TEST_ASSERT (counter == 1);
mode = 1;
@@ -195,20 +194,17 @@ main (void)
mode = 5;
counter = 0;
- do_eval (TEST_STRING_LITERAL ("native()\n"),
- true);
+ do_eval (TEST_STRING_LITERAL ("native()\n"), true);
TEST_ASSERT (counter == 1);
mode = 6;
counter = 0;
- do_eval (TEST_STRING_LITERAL ("native()\n"),
- true);
+ do_eval (TEST_STRING_LITERAL ("native()\n"), true);
TEST_ASSERT (counter == 2);
mode = 7;
counter = 0;
- do_eval (TEST_STRING_LITERAL ("native()\n"),
- true);
+ do_eval (TEST_STRING_LITERAL ("native()\n"), true);
TEST_ASSERT (counter == 0);
/* Built-in functions should not trigger the call twice: */
diff --git a/tests/unit-ext/module/jerry-module-test.c b/tests/unit-ext/module/jerry-module-test.c
index a62aa6fc..201b3846 100644
--- a/tests/unit-ext/module/jerry-module-test.c
+++ b/tests/unit-ext/module/jerry-module-test.c
@@ -16,8 +16,9 @@
#include <string.h>
#include "jerryscript.h"
-#include "test-common.h"
+
#include "jerryscript-ext/module.h"
+#include "test-common.h"
/* Load a module. */
const char eval_string1[] = "require ('my_custom_module');";
@@ -26,64 +27,58 @@ const char eval_string1[] = "require ('my_custom_module');";
const char eval_string2[] = "require ('differently-handled-module');";
/* Load a broken module using the built-in resolver. */
-const char eval_string3[] =
-"(function() {"
-" var theError;"
-" try {"
-" require ('my_broken_module');"
-" } catch (anError) {"
-" theError = anError;"
-" }"
-" return (((theError.message === 'Module on_resolve () must not be NULL') &&"
-" (theError.moduleName === 'my_broken_module') &&"
-" (theError instanceof TypeError)) ? 1 : 0);"
-"}) ();";
+const char eval_string3[] = "(function() {"
+ " var theError;"
+ " try {"
+ " require ('my_broken_module');"
+ " } catch (anError) {"
+ " theError = anError;"
+ " }"
+ " return (((theError.message === 'Module on_resolve () must not be NULL') &&"
+ " (theError.moduleName === 'my_broken_module') &&"
+ " (theError instanceof TypeError)) ? 1 : 0);"
+ "}) ();";
/* Load a non-existent module. */
-const char eval_string4[] =
-"(function() {"
-" var theError;"
-" try {"
-" require ('some_missing_module_xyzzy');"
-" } catch (anError) {"
-" theError = anError;"
-" }"
-" return (((theError.message === 'Module not found') &&"
-" (theError.moduleName === 'some_missing_module_xyzzy')) ? 1 : 0);"
-"}) ();";
+const char eval_string4[] = "(function() {"
+ " var theError;"
+ " try {"
+ " require ('some_missing_module_xyzzy');"
+ " } catch (anError) {"
+ " theError = anError;"
+ " }"
+ " return (((theError.message === 'Module not found') &&"
+ " (theError.moduleName === 'some_missing_module_xyzzy')) ? 1 : 0);"
+ "}) ();";
/* Make sure the result of a module load is cached. */
-const char eval_string5[] =
-"(function() {"
-" var x = require('cache-check');"
-" var y = require('cache-check');"
-" return x === y ? 1 : 0;"
-"}) ();";
+const char eval_string5[] = "(function() {"
+ " var x = require('cache-check');"
+ " var y = require('cache-check');"
+ " return x === y ? 1 : 0;"
+ "}) ();";
/* Make sure the result of a module load is removed from the cache. */
-const char eval_string6[] =
-"(function() {"
-" var x = require('cache-check');"
-" clear_require_cache('cache-check');"
-" var y = require('cache-check');"
-" return x !== y ? 1 : 0;"
-"}) ();";
+const char eval_string6[] = "(function() {"
+ " var x = require('cache-check');"
+ " clear_require_cache('cache-check');"
+ " var y = require('cache-check');"
+ " return x !== y ? 1 : 0;"
+ "}) ();";
/* Make sure the entire cache is cleared. */
-const char eval_string7[] =
-"(function() {"
-" var x = require('cache-check');"
-" clear_require_cache(undefined);"
-" var y = require('cache-check');"
-" return x !== y ? 1 : 0;"
-"}) ();";
+const char eval_string7[] = "(function() {"
+ " var x = require('cache-check');"
+ " clear_require_cache(undefined);"
+ " var y = require('cache-check');"
+ " return x !== y ? 1 : 0;"
+ "}) ();";
/*
* Define a resolver for a module named "differently-handled-module" to check that custom resolvers work.
*/
static bool
-resolve_differently_handled_module (const jerry_value_t name,
- jerry_value_t *result)
+resolve_differently_handled_module (const jerry_value_t name, jerry_value_t *result)
{
jerry_size_t name_size = jerry_get_utf8_string_size (name);
JERRY_VLA (jerry_char_t, name_string, name_size);
@@ -97,11 +92,7 @@ resolve_differently_handled_module (const jerry_value_t name,
return false;
} /* resolve_differently_handled_module */
-static jerryx_module_resolver_t differently_handled_module_resolver =
-{
- NULL,
- resolve_differently_handled_module
-};
+static jerryx_module_resolver_t differently_handled_module_resolver = { NULL, resolve_differently_handled_module };
/*
* Define module "cache-check" via its own resolver as an empty object. Since objects are accessible only via references
@@ -109,8 +100,7 @@ static jerryx_module_resolver_t differently_handled_module_resolver =
* on the first attempt and establish that the two are in fact the same object - which in turn shows that caching works.
*/
static bool
-cache_check (const jerry_value_t name,
- jerry_value_t *result)
+cache_check (const jerry_value_t name, jerry_value_t *result)
{
jerry_size_t name_size = jerry_get_utf8_string_size (name);
JERRY_VLA (jerry_char_t, name_string, name_size);
@@ -124,18 +114,11 @@ cache_check (const jerry_value_t name,
return false;
} /* cache_check */
-static jerryx_module_resolver_t cache_check_resolver =
-{
- NULL,
- cache_check
-};
+static jerryx_module_resolver_t cache_check_resolver = { NULL, cache_check };
-static const jerryx_module_resolver_t *resolvers[3] =
-{
- &jerryx_module_native_resolver,
- &differently_handled_module_resolver,
- &cache_check_resolver
-};
+static const jerryx_module_resolver_t *resolvers[3] = { &jerryx_module_native_resolver,
+ &differently_handled_module_resolver,
+ &cache_check_resolver };
static jerry_value_t
handle_clear_require_cache (const jerry_call_info_t *call_info_p,
@@ -152,9 +135,7 @@ handle_clear_require_cache (const jerry_call_info_t *call_info_p,
} /* handle_clear_require_cache */
static jerry_value_t
-handle_require (const jerry_call_info_t *call_info_p,
- const jerry_value_t args_p[],
- const jerry_length_t args_count)
+handle_require (const jerry_call_info_t *call_info_p, const jerry_value_t args_p[], const jerry_length_t args_count)
{
(void) call_info_p;
(void) args_count;
@@ -177,9 +158,8 @@ assert_number (jerry_value_t js_value, double expected_result)
static void
eval_one (const char *the_string, double expected_result)
{
- jerry_value_t js_eval_result = jerry_eval ((const jerry_char_t *) the_string,
- strlen (the_string),
- JERRY_PARSE_STRICT_MODE);
+ jerry_value_t js_eval_result =
+ jerry_eval ((const jerry_char_t *) the_string, strlen (the_string), JERRY_PARSE_STRICT_MODE);
assert_number (js_eval_result, expected_result);
jerry_release_value (js_eval_result);
} /* eval_one */
diff --git a/tests/unit-ext/module/my-broken-module.c b/tests/unit-ext/module/my-broken-module.c
index 39d4112a..1081770e 100644
--- a/tests/unit-ext/module/my-broken-module.c
+++ b/tests/unit-ext/module/my-broken-module.c
@@ -14,6 +14,7 @@
*/
#include "jerryscript.h"
+
#include "jerryscript-ext/module.h"
#define MODULE_NAME my_broken_module
diff --git a/tests/unit-ext/module/my-custom-module.c b/tests/unit-ext/module/my-custom-module.c
index 541e971d..ab7800e6 100644
--- a/tests/unit-ext/module/my-custom-module.c
+++ b/tests/unit-ext/module/my-custom-module.c
@@ -14,6 +14,7 @@
*/
#include "jerryscript.h"
+
#include "jerryscript-ext/module.h"
#define MODULE_NAME my_custom_module
diff --git a/tests/unit-ext/test-common.h b/tests/unit-ext/test-common.h
index cbc4feb9..b65772c2 100644
--- a/tests/unit-ext/test-common.h
+++ b/tests/unit-ext/test-common.h
@@ -22,19 +22,19 @@
#define JERRY_UNUSED(x) ((void) (x))
-#define TEST_ASSERT(x) \
- do \
- { \
- if (!(x)) \
- { \
- jerry_port_log (JERRY_LOG_LEVEL_ERROR, \
+#define TEST_ASSERT(x) \
+ do \
+ { \
+ if (!(x)) \
+ { \
+ jerry_port_log (JERRY_LOG_LEVEL_ERROR, \
"TEST: Assertion '%s' failed at %s(%s):%lu.\n", \
- #x, \
- __FILE__, \
- __func__, \
- (unsigned long) __LINE__); \
- jerry_port_fatal (ERR_FAILED_INTERNAL_ASSERTION); \
- } \
+ #x, \
+ __FILE__, \
+ __func__, \
+ (unsigned long) __LINE__); \
+ jerry_port_fatal (ERR_FAILED_INTERNAL_ASSERTION); \
+ } \
} while (0)
#define TEST_STRING_LITERAL(x) x
diff --git a/tests/unit-ext/test-ext-arg.c b/tests/unit-ext/test-ext-arg.c
index fa1c47f3..49f8657b 100644
--- a/tests/unit-ext/test-ext-arg.c
+++ b/tests/unit-ext/test-ext-arg.c
@@ -18,62 +18,61 @@
*/
#include <string.h>
+
#include "jerryscript.h"
+
#include "jerryscript-ext/arg.h"
#include "test-common.h"
-static const jerry_char_t test_source[] = TEST_STRING_LITERAL (
- "var arg1 = true;"
- "var arg2 = 10.5;"
- "var arg3 = 'abc';"
- "var arg4 = function foo() {};"
- "test_validator1(arg1, arg2, arg3, arg4);"
- "arg1 = new Boolean(true);"
- "arg3 = new String('abc');"
- "test_validator1(arg1, arg2, arg3);"
- "test_validator1(arg1, arg2, '');"
- "arg2 = new Number(10.5);"
- "test_validator1(arg1, arg2, arg3);"
- "test_validator1(arg1, 10.5, 'abcdef');"
- "test_validator3(arg1, arg1);"
- "test_validator3(arg1);"
- "test_validator3();"
- "test_validator3(undefined, undefined);"
- "var obj_a = new MyObjectA();"
- "var obj_b = new MyObjectB();"
- "test_validator2.call(obj_a, 5);"
- "test_validator2.call(obj_b, 5);"
- "test_validator2.call(obj_a, 1);"
- "var obj1 = {prop1:true, prop2:'1.5'};"
- "test_validator_prop1(obj1);"
- "test_validator_prop2(obj1);"
- "test_validator_prop2();"
- "var obj2 = {prop1:true};"
- "Object.defineProperty(obj2, 'prop2', {"
- " get: function() { throw new TypeError('prop2 error') }"
- "});"
- "test_validator_prop3(obj2);"
- "test_validator_int1(-1000, 1000, 128, -1000, 1000, -127,"
- " -1000, 4294967297, 65536, -2200000000, 4294967297, -2147483647);"
- "test_validator_int2(-1.5, -1.5, -1.5, 1.5, 1.5, 1.5, Infinity, -Infinity, 300.5, 300.5);"
- "test_validator_int3(NaN);"
- "var arr = [1, 2];"
- "test_validator_array1(arr);"
- "test_validator_array1();"
- "test_validator_array2(arr);"
- "test_validator_restore(false, 3.0);"
- "test_validator_restore(3.0, false);"
-);
-
-static const jerry_object_native_info_t thing_a_info =
-{
+static const jerry_char_t test_source[] =
+ TEST_STRING_LITERAL ("var arg1 = true;"
+ "var arg2 = 10.5;"
+ "var arg3 = 'abc';"
+ "var arg4 = function foo() {};"
+ "test_validator1(arg1, arg2, arg3, arg4);"
+ "arg1 = new Boolean(true);"
+ "arg3 = new String('abc');"
+ "test_validator1(arg1, arg2, arg3);"
+ "test_validator1(arg1, arg2, '');"
+ "arg2 = new Number(10.5);"
+ "test_validator1(arg1, arg2, arg3);"
+ "test_validator1(arg1, 10.5, 'abcdef');"
+ "test_validator3(arg1, arg1);"
+ "test_validator3(arg1);"
+ "test_validator3();"
+ "test_validator3(undefined, undefined);"
+ "var obj_a = new MyObjectA();"
+ "var obj_b = new MyObjectB();"
+ "test_validator2.call(obj_a, 5);"
+ "test_validator2.call(obj_b, 5);"
+ "test_validator2.call(obj_a, 1);"
+ "var obj1 = {prop1:true, prop2:'1.5'};"
+ "test_validator_prop1(obj1);"
+ "test_validator_prop2(obj1);"
+ "test_validator_prop2();"
+ "var obj2 = {prop1:true};"
+ "Object.defineProperty(obj2, 'prop2', {"
+ " get: function() { throw new TypeError('prop2 error') }"
+ "});"
+ "test_validator_prop3(obj2);"
+ "test_validator_int1(-1000, 1000, 128, -1000, 1000, -127,"
+ " -1000, 4294967297, 65536, -2200000000, 4294967297, -2147483647);"
+ "test_validator_int2(-1.5, -1.5, -1.5, 1.5, 1.5, 1.5, Infinity, -Infinity, 300.5, 300.5);"
+ "test_validator_int3(NaN);"
+ "var arr = [1, 2];"
+ "test_validator_array1(arr);"
+ "test_validator_array1();"
+ "test_validator_array2(arr);"
+ "test_validator_restore(false, 3.0);"
+ "test_validator_restore(3.0, false);");
+
+static const jerry_object_native_info_t thing_a_info = {
.free_cb = NULL,
.number_of_references = 0,
.offset_of_references = 0,
};
-static const jerry_object_native_info_t thing_b_info =
-{
+static const jerry_object_native_info_t thing_b_info = {
.free_cb = NULL,
.number_of_references = 0,
.offset_of_references = 0,
@@ -119,25 +118,20 @@ test_validator1_handler (const jerry_call_info_t *call_info_p, /**< call informa
char arg3[5] = "1234";
jerry_value_t arg4 = jerry_create_undefined ();
- jerryx_arg_t mapping[] =
- {
- /* ignore this */
- jerryx_arg_ignore (),
- /* 1st argument should be boolean */
- jerryx_arg_boolean (&arg1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
- /* 2nd argument should be strict number */
- jerryx_arg_number (&arg2, JERRYX_ARG_NO_COERCE, JERRYX_ARG_REQUIRED),
- /* 3th argument should be string */
- jerryx_arg_string (arg3, 5, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
- /* 4th argument should be function, and it is optional */
- jerryx_arg_function (&arg4, JERRYX_ARG_OPTIONAL)
+ jerryx_arg_t mapping[] = { /* ignore this */
+ jerryx_arg_ignore (),
+ /* 1st argument should be boolean */
+ jerryx_arg_boolean (&arg1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
+ /* 2nd argument should be strict number */
+ jerryx_arg_number (&arg2, JERRYX_ARG_NO_COERCE, JERRYX_ARG_REQUIRED),
+ /* 3th argument should be string */
+ jerryx_arg_string (arg3, 5, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
+ /* 4th argument should be function, and it is optional */
+ jerryx_arg_function (&arg4, JERRYX_ARG_OPTIONAL)
};
- jerry_value_t is_ok = jerryx_arg_transform_this_and_args (call_info_p->this_value,
- args_p,
- args_cnt,
- mapping,
- ARRAY_SIZE (mapping));
+ jerry_value_t is_ok =
+ jerryx_arg_transform_this_and_args (call_info_p->this_value, args_p, args_cnt, mapping, ARRAY_SIZE (mapping));
if (validator1_count == 0)
{
@@ -189,8 +183,7 @@ my_custom_transform (jerryx_arg_js_iterator_t *js_arg_iter_p, /**< available JS
{
jerry_release_value (to_number);
- return jerry_create_error (JERRY_ERROR_TYPE,
- (jerry_char_t *) "It can not be converted to a number.");
+ return jerry_create_error (JERRY_ERROR_TYPE, (jerry_char_t *) "It can not be converted to a number.");
}
int expected_num = (int) c_arg_p->extra_info;
@@ -198,8 +191,7 @@ my_custom_transform (jerryx_arg_js_iterator_t *js_arg_iter_p, /**< available JS
if (get_num != expected_num)
{
- return jerry_create_error (JERRY_ERROR_TYPE,
- (jerry_char_t *) "Number value is not expected.");
+ return jerry_create_error (JERRY_ERROR_TYPE, (jerry_char_t *) "Number value is not expected.");
}
return jerry_create_undefined ();
@@ -217,19 +209,14 @@ test_validator2_handler (const jerry_call_info_t *call_info_p, /**< call informa
{
my_type_a_t *thing_p;
- jerryx_arg_t mapping[] =
- {
- /* this should has native pointer, whose type is thing_a_info */
- jerryx_arg_native_pointer ((void **) &thing_p, &thing_a_info, JERRYX_ARG_REQUIRED),
- /* custom tranform function */
- jerryx_arg_custom (NULL, 5, my_custom_transform)
+ jerryx_arg_t mapping[] = { /* this should has native pointer, whose type is thing_a_info */
+ jerryx_arg_native_pointer ((void **) &thing_p, &thing_a_info, JERRYX_ARG_REQUIRED),
+ /* custom tranform function */
+ jerryx_arg_custom (NULL, 5, my_custom_transform)
};
- jerry_value_t is_ok = jerryx_arg_transform_this_and_args (call_info_p->this_value,
- args_p,
- args_cnt,
- mapping,
- ARRAY_SIZE (mapping));
+ jerry_value_t is_ok =
+ jerryx_arg_transform_this_and_args (call_info_p->this_value, args_p, args_cnt, mapping, ARRAY_SIZE (mapping));
if (validator2_count == 0)
{
@@ -261,8 +248,7 @@ test_validator3_handler (const jerry_call_info_t *call_info_p, /**< call informa
bool arg1 = false;
bool arg2 = false;
- jerryx_arg_t mapping[] =
- {
+ jerryx_arg_t mapping[] = {
/* ignore this */
jerryx_arg_ignore (),
/* 1th argument should be boolean, and it is optional */
@@ -271,11 +257,8 @@ test_validator3_handler (const jerry_call_info_t *call_info_p, /**< call informa
jerryx_arg_boolean (&arg2, JERRYX_ARG_COERCE, JERRYX_ARG_OPTIONAL),
};
- jerry_value_t is_ok = jerryx_arg_transform_this_and_args (call_info_p->this_value,
- args_p,
- args_cnt,
- mapping,
- ARRAY_SIZE (mapping));
+ jerry_value_t is_ok =
+ jerryx_arg_transform_this_and_args (call_info_p->this_value, args_p, args_cnt, mapping, ARRAY_SIZE (mapping));
if (validator3_count == 0)
{
@@ -328,14 +311,11 @@ test_validator_prop1_handler (const jerry_call_info_t *call_info_p, /**< call in
double native2 = 0;
double native3 = 3;
- const char *name_p[] = {"prop1", "prop2", "prop3"};
+ const char *name_p[] = { "prop1", "prop2", "prop3" };
- jerryx_arg_t mapping[] =
- {
- jerryx_arg_boolean (&native1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
- jerryx_arg_number (&native2, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
- jerryx_arg_number (&native3, JERRYX_ARG_COERCE, JERRYX_ARG_OPTIONAL)
- };
+ jerryx_arg_t mapping[] = { jerryx_arg_boolean (&native1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
+ jerryx_arg_number (&native2, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
+ jerryx_arg_number (&native3, JERRYX_ARG_COERCE, JERRYX_ARG_OPTIONAL) };
jerry_value_t is_ok = jerryx_arg_transform_object_properties (args_p[0],
(const jerry_char_t **) name_p,
@@ -372,20 +352,16 @@ test_validator_prop2_handler (const jerry_call_info_t *call_info_p, /**< call in
const char *name_p[] = { "prop1", "prop2", "prop3" };
- jerryx_arg_t prop_mapping[] =
- {
- jerryx_arg_boolean (&native1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
- jerryx_arg_number (&native2, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
- jerryx_arg_number (&native3, JERRYX_ARG_COERCE, JERRYX_ARG_OPTIONAL)
- };
+ jerryx_arg_t prop_mapping[] = { jerryx_arg_boolean (&native1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
+ jerryx_arg_number (&native2, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
+ jerryx_arg_number (&native3, JERRYX_ARG_COERCE, JERRYX_ARG_OPTIONAL) };
prop_info.name_p = (const jerry_char_t **) name_p;
prop_info.name_cnt = 3;
prop_info.c_arg_p = prop_mapping;
prop_info.c_arg_cnt = 3;
- jerryx_arg_t mapping[] =
- {
+ jerryx_arg_t mapping[] = {
jerryx_arg_object_properties (&prop_info, JERRYX_ARG_OPTIONAL),
};
@@ -418,8 +394,7 @@ test_validator_prop3_handler (const jerry_call_info_t *call_info_p, /**< call in
const char *name_p[] = { "prop1", "prop2" };
- jerryx_arg_t mapping[] =
- {
+ jerryx_arg_t mapping[] = {
jerryx_arg_boolean (&native1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
jerryx_arg_boolean (&native2, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
};
@@ -455,8 +430,7 @@ test_validator_int1_handler (const jerry_call_info_t *call_info_p, /**< call inf
uint32_t num6, num7, num8;
int32_t num9, num10, num11;
- jerryx_arg_t mapping[] =
- {
+ jerryx_arg_t mapping[] = {
jerryx_arg_uint8 (&num0, JERRYX_ARG_ROUND, JERRYX_ARG_CLAMP, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
jerryx_arg_uint8 (&num1, JERRYX_ARG_ROUND, JERRYX_ARG_CLAMP, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
jerryx_arg_uint8 (&num2, JERRYX_ARG_ROUND, JERRYX_ARG_CLAMP, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
@@ -471,10 +445,7 @@ test_validator_int1_handler (const jerry_call_info_t *call_info_p, /**< call inf
jerryx_arg_int32 (&num11, JERRYX_ARG_ROUND, JERRYX_ARG_CLAMP, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED)
};
- jerry_value_t is_ok = jerryx_arg_transform_args (args_p,
- args_cnt,
- mapping,
- ARRAY_SIZE (mapping));
+ jerry_value_t is_ok = jerryx_arg_transform_args (args_p, args_cnt, mapping, ARRAY_SIZE (mapping));
TEST_ASSERT (!jerry_value_is_error (is_ok));
TEST_ASSERT (num0 == 0);
@@ -507,8 +478,7 @@ test_validator_int2_handler (const jerry_call_info_t *call_info_p, /**< call inf
num8 = 123;
num9 = 123;
- jerryx_arg_t mapping[] =
- {
+ jerryx_arg_t mapping[] = {
jerryx_arg_int8 (&num0, JERRYX_ARG_ROUND, JERRYX_ARG_CLAMP, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
jerryx_arg_int8 (&num1, JERRYX_ARG_FLOOR, JERRYX_ARG_CLAMP, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
jerryx_arg_int8 (&num2, JERRYX_ARG_CEIL, JERRYX_ARG_CLAMP, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
@@ -521,10 +491,7 @@ test_validator_int2_handler (const jerry_call_info_t *call_info_p, /**< call inf
jerryx_arg_int8 (&num9, JERRYX_ARG_ROUND, JERRYX_ARG_NO_CLAMP, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
};
- jerry_value_t is_ok = jerryx_arg_transform_args (args_p,
- args_cnt,
- mapping,
- ARRAY_SIZE (mapping));
+ jerry_value_t is_ok = jerryx_arg_transform_args (args_p, args_cnt, mapping, ARRAY_SIZE (mapping));
TEST_ASSERT (jerry_value_is_error (is_ok));
TEST_ASSERT (num0 == -2);
@@ -553,15 +520,11 @@ test_validator_int3_handler (const jerry_call_info_t *call_info_p, /**< call inf
int8_t num0;
- jerryx_arg_t mapping[] =
- {
+ jerryx_arg_t mapping[] = {
jerryx_arg_int8 (&num0, JERRYX_ARG_ROUND, JERRYX_ARG_CLAMP, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
};
- jerry_value_t is_ok = jerryx_arg_transform_args (args_p,
- args_cnt,
- mapping,
- ARRAY_SIZE (mapping));
+ jerry_value_t is_ok = jerryx_arg_transform_args (args_p, args_cnt, mapping, ARRAY_SIZE (mapping));
TEST_ASSERT (jerry_value_is_error (is_ok));
@@ -584,18 +547,14 @@ test_validator_array1_handler (const jerry_call_info_t *call_info_p, /**< call i
jerryx_arg_array_items_t arr_info;
- jerryx_arg_t item_mapping[] =
- {
- jerryx_arg_number (&native1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
- jerryx_arg_number (&native2, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
- jerryx_arg_number (&native3, JERRYX_ARG_COERCE, JERRYX_ARG_OPTIONAL)
- };
+ jerryx_arg_t item_mapping[] = { jerryx_arg_number (&native1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
+ jerryx_arg_number (&native2, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
+ jerryx_arg_number (&native3, JERRYX_ARG_COERCE, JERRYX_ARG_OPTIONAL) };
arr_info.c_arg_p = item_mapping;
arr_info.c_arg_cnt = 3;
- jerryx_arg_t mapping[] =
- {
+ jerryx_arg_t mapping[] = {
jerryx_arg_array (&arr_info, JERRYX_ARG_OPTIONAL),
};
@@ -626,11 +585,8 @@ test_validator_array2_handler (const jerry_call_info_t *call_info_p, /**< call i
double native1 = 0;
bool native2 = false;
- jerryx_arg_t item_mapping[] =
- {
- jerryx_arg_number (&native1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
- jerryx_arg_boolean (&native2, JERRYX_ARG_NO_COERCE, JERRYX_ARG_REQUIRED)
- };
+ jerryx_arg_t item_mapping[] = { jerryx_arg_number (&native1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
+ jerryx_arg_boolean (&native2, JERRYX_ARG_NO_COERCE, JERRYX_ARG_REQUIRED) };
jerry_value_t is_ok = jerryx_arg_transform_array (args_p[0], item_mapping, ARRAY_SIZE (item_mapping));
@@ -654,10 +610,10 @@ test_validator_array2_handler (const jerry_call_info_t *call_info_p, /**< call i
* against backing up too far, when the check for the double fails,
* we'll "restore" the stack three times; this shouldn't break
* anything.
-*/
+ */
/*
* This enumeration type specifies the kind of thing held in the union.
-*/
+ */
typedef enum
{
DOUBLE_VALUE,
@@ -667,7 +623,7 @@ typedef enum
/*
* This struct holds either a boolean or double in a union and has a
* second field that describes the type held in the union.
-*/
+ */
typedef struct
{
union_type_t type_of_value;
@@ -682,21 +638,20 @@ typedef struct
* This creates a jerryx_arg_t that can be used like any
* of the installed functions, like jerryx_arg_bool().
*/
-#define jerryx_arg_double_or_bool_t(value_ptr, coerce_or_not, optional_or_not, last_parameter) \
- jerryx_arg_custom (value_ptr, \
- (uintptr_t)&((uintptr_t []){(uintptr_t)coerce_or_not, \
- (uintptr_t)optional_or_not, \
- (uintptr_t)last_parameter}), \
- jerry_arg_to_double_or_bool_t)
+#define jerryx_arg_double_or_bool_t(value_ptr, coerce_or_not, optional_or_not, last_parameter) \
+ jerryx_arg_custom ( \
+ value_ptr, \
+ (uintptr_t) \
+ & ((uintptr_t[]){ (uintptr_t) coerce_or_not, (uintptr_t) optional_or_not, (uintptr_t) last_parameter }), \
+ jerry_arg_to_double_or_bool_t)
/*
* This function is the argument validator used in the above macro called
* jerryx_arg_double_or_bool. It calls jerryx_arg_js_iterator_restore()
* more times than it should to ensure that calling that function too
* often doesn't cause an error.
-*/
+ */
static jerry_value_t
-jerry_arg_to_double_or_bool_t (jerryx_arg_js_iterator_t *js_arg_iter_p,
- const jerryx_arg_t *c_arg_p)
+jerry_arg_to_double_or_bool_t (jerryx_arg_js_iterator_t *js_arg_iter_p, const jerryx_arg_t *c_arg_p)
{
/* c_arg_p has two fields: dest, which is a pointer to the data that
* gets filled in, and extra_info, which contains the flags used to
@@ -763,14 +718,13 @@ jerry_arg_to_double_or_bool_t (jerryx_arg_js_iterator_t *js_arg_iter_p,
/* Fall through indicates that whatever they gave us, it wasn't
* one of the types we were expecting... */
jerry_release_value (conversion_result);
- return jerry_create_error (JERRY_ERROR_TYPE,
- (const jerry_char_t *) "double_or_bool-type error.");
+ return jerry_create_error (JERRY_ERROR_TYPE, (const jerry_char_t *) "double_or_bool-type error.");
} /* jerry_arg_to_double_or_bool_t */
/**
* This validator expects two parameters, one a bool and one a double -- the
* order doesn't matter (so we'll call it twice with the orders reversed).
-*/
+ */
static jerry_value_t
test_validator_restore_handler (const jerry_call_info_t *call_info_p, /**< call information */
const jerry_value_t args_p[], /**< arguments list */
@@ -781,11 +735,8 @@ test_validator_restore_handler (const jerry_call_info_t *call_info_p, /**< call
double_or_bool_t arg1;
double_or_bool_t arg2;
- jerryx_arg_t item_mapping[] =
- {
- jerryx_arg_double_or_bool_t (&arg1, JERRYX_ARG_NO_COERCE, JERRYX_ARG_REQUIRED, 0),
- jerryx_arg_double_or_bool_t (&arg2, JERRYX_ARG_NO_COERCE, JERRYX_ARG_REQUIRED, 1)
- };
+ jerryx_arg_t item_mapping[] = { jerryx_arg_double_or_bool_t (&arg1, JERRYX_ARG_NO_COERCE, JERRYX_ARG_REQUIRED, 0),
+ jerryx_arg_double_or_bool_t (&arg2, JERRYX_ARG_NO_COERCE, JERRYX_ARG_REQUIRED, 1) };
jerry_value_t is_ok = jerryx_arg_transform_args (args_p, args_cnt, item_mapping, ARRAY_SIZE (item_mapping));
@@ -812,15 +763,11 @@ test_utf8_string (void)
size_t buf_len = sizeof (expect_utf8_buf) - 1;
JERRY_VLA (char, buf, buf_len + 1);
- jerryx_arg_t mapping[] =
- {
+ jerryx_arg_t mapping[] = {
jerryx_arg_utf8_string (buf, (uint32_t) buf_len + 1, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
};
- jerry_value_t is_ok = jerryx_arg_transform_args (&str,
- 1,
- mapping,
- ARRAY_SIZE (mapping));
+ jerry_value_t is_ok = jerryx_arg_transform_args (&str, 1, mapping, ARRAY_SIZE (mapping));
TEST_ASSERT (!jerry_value_is_error (is_ok));
TEST_ASSERT (!strcmp (buf, expect_utf8_buf));
@@ -839,9 +786,7 @@ create_object_a_handler (const jerry_call_info_t *call_info_p, /**< call informa
TEST_ASSERT (jerry_value_is_object (call_info_p->this_value));
my_thing_a.x = 1;
- jerry_set_object_native_pointer (call_info_p->this_value,
- &my_thing_a,
- &thing_a_info);
+ jerry_set_object_native_pointer (call_info_p->this_value, &my_thing_a, &thing_a_info);
return jerry_create_boolean (true);
} /* create_object_a_handler */
@@ -857,9 +802,7 @@ create_object_b_handler (const jerry_call_info_t *call_info_p, /**< call informa
TEST_ASSERT (jerry_value_is_object (call_info_p->this_value));
my_thing_b.x = false;
- jerry_set_object_native_pointer (call_info_p->this_value,
- &my_thing_b,
- &thing_b_info);
+ jerry_set_object_native_pointer (call_info_p->this_value, &my_thing_b, &thing_b_info);
return jerry_create_boolean (true);
} /* create_object_b_handler */
@@ -906,9 +849,7 @@ main (void)
register_js_function ("test_validator_array2", test_validator_array2_handler);
register_js_function ("test_validator_restore", test_validator_restore_handler);
- jerry_value_t parsed_code_val = jerry_parse (test_source,
- sizeof (test_source) - 1,
- NULL);
+ jerry_value_t parsed_code_val = jerry_parse (test_source, sizeof (test_source) - 1, NULL);
TEST_ASSERT (!jerry_value_is_error (parsed_code_val));
jerry_value_t res = jerry_run (parsed_code_val);
diff --git a/tests/unit-ext/test-ext-autorelease.c b/tests/unit-ext/test-ext-autorelease.c
index f545df66..235f64ba 100644
--- a/tests/unit-ext/test-ext-autorelease.c
+++ b/tests/unit-ext/test-ext-autorelease.c
@@ -18,6 +18,7 @@
*/
#include "jerryscript.h"
+
#include "jerryscript-ext/autorelease.h"
#include "test-common.h"
@@ -32,8 +33,7 @@ native_free_cb (void *native_p, /**< native pointer */
++native_free_cb_call_count;
} /* native_free_cb */
-static const jerry_object_native_info_t native_info =
-{
+static const jerry_object_native_info_t native_info = {
.free_cb = native_free_cb,
.number_of_references = 0,
.offset_of_references = 0,
diff --git a/tests/unit-ext/test-ext-handle-scope-escape.c b/tests/unit-ext/test-ext-handle-scope-escape.c
index e1daffe9..b967e057 100644
--- a/tests/unit-ext/test-ext-handle-scope-escape.c
+++ b/tests/unit-ext/test-ext-handle-scope-escape.c
@@ -18,6 +18,7 @@
*/
#include "jerryscript.h"
+
#include "jerryscript-ext/handle-scope.h"
#include "test-common.h"
@@ -32,8 +33,7 @@ native_free_cb (void *native_p, /**< native pointer */
++native_free_cb_call_count;
} /* native_free_cb */
-static const jerry_object_native_info_t native_info =
-{
+static const jerry_object_native_info_t native_info = {
.free_cb = native_free_cb,
.number_of_references = 0,
.offset_of_references = 0,
diff --git a/tests/unit-ext/test-ext-handle-scope-handle-prelist-escape.c b/tests/unit-ext/test-ext-handle-scope-handle-prelist-escape.c
index e8ff8d46..9070d6d4 100644
--- a/tests/unit-ext/test-ext-handle-scope-handle-prelist-escape.c
+++ b/tests/unit-ext/test-ext-handle-scope-handle-prelist-escape.c
@@ -20,6 +20,7 @@
*/
#include "jerryscript.h"
+
#include "jerryscript-ext/handle-scope.h"
#include "test-common.h"
@@ -35,8 +36,7 @@ native_free_cb (void *native_p, /**< native pointer */
++native_free_cb_call_count;
} /* native_free_cb */
-static const jerry_object_native_info_t native_info =
-{
+static const jerry_object_native_info_t native_info = {
.free_cb = native_free_cb,
.number_of_references = 0,
.offset_of_references = 0,
@@ -49,7 +49,7 @@ create_object (void)
jerryx_open_escapable_handle_scope (&scope);
jerry_value_t obj;
- for (size_t idx = 0; idx < handle_count; idx ++)
+ for (size_t idx = 0; idx < handle_count; idx++)
{
obj = jerryx_create_handle (jerry_create_object ());
jerry_set_object_native_pointer (obj, NULL, &native_info);
@@ -73,7 +73,7 @@ test_handle_scope_val (void)
(void) obj;
jerry_gc (JERRY_GC_PRESSURE_LOW);
- TEST_ASSERT (native_free_cb_call_count == (handle_count -1));
+ TEST_ASSERT (native_free_cb_call_count == (handle_count - 1));
jerryx_close_handle_scope (scope);
} /* test_handle_scope_val */
diff --git a/tests/unit-ext/test-ext-handle-scope-handle-prelist.c b/tests/unit-ext/test-ext-handle-scope-handle-prelist.c
index 9b2dd097..e00d0fa8 100644
--- a/tests/unit-ext/test-ext-handle-scope-handle-prelist.c
+++ b/tests/unit-ext/test-ext-handle-scope-handle-prelist.c
@@ -20,6 +20,7 @@
*/
#include "jerryscript.h"
+
#include "jerryscript-ext/handle-scope.h"
#include "test-common.h"
@@ -35,8 +36,7 @@ native_free_cb (void *native_p, /**< native pointer */
++native_free_cb_call_count;
} /* native_free_cb */
-static const jerry_object_native_info_t native_info =
-{
+static const jerry_object_native_info_t native_info = {
.free_cb = native_free_cb,
.number_of_references = 0,
.offset_of_references = 0,
@@ -49,7 +49,7 @@ create_object (void)
jerryx_open_escapable_handle_scope (&scope);
jerry_value_t obj;
- for (size_t idx = 0; idx < handle_count; idx ++)
+ for (size_t idx = 0; idx < handle_count; idx++)
{
obj = jerryx_create_handle (jerry_create_object ());
jerry_set_object_native_pointer (obj, NULL, &native_info);
@@ -73,7 +73,7 @@ test_handle_scope_val (void)
(void) obj;
jerry_gc (JERRY_GC_PRESSURE_LOW);
- TEST_ASSERT (native_free_cb_call_count == (handle_count -1));
+ TEST_ASSERT (native_free_cb_call_count == (handle_count - 1));
jerryx_close_handle_scope (scope);
} /* test_handle_scope_val */
diff --git a/tests/unit-ext/test-ext-handle-scope-nested.c b/tests/unit-ext/test-ext-handle-scope-nested.c
index 6f4cd37f..9e7a16a3 100644
--- a/tests/unit-ext/test-ext-handle-scope-nested.c
+++ b/tests/unit-ext/test-ext-handle-scope-nested.c
@@ -21,6 +21,7 @@
*/
#include "jerryscript.h"
+
#include "jerryscript-ext/handle-scope.h"
#include "test-common.h"
@@ -35,8 +36,7 @@ native_free_cb (void *native_p, /**< native pointer */
++native_free_cb_call_count;
} /* native_free_cb */
-static const jerry_object_native_info_t native_info =
-{
+static const jerry_object_native_info_t native_info = {
.free_cb = native_free_cb,
.number_of_references = 0,
.offset_of_references = 0,
diff --git a/tests/unit-ext/test-ext-handle-scope-remove.c b/tests/unit-ext/test-ext-handle-scope-remove.c
index dccc5c0d..c1dacba7 100644
--- a/tests/unit-ext/test-ext-handle-scope-remove.c
+++ b/tests/unit-ext/test-ext-handle-scope-remove.c
@@ -18,6 +18,7 @@
*/
#include "jerryscript.h"
+
#include "jerryscript-ext/handle-scope.h"
#include "test-common.h"
@@ -32,8 +33,7 @@ native_free_cb (void *native_p, /**< native pointer */
++native_free_cb_call_count;
} /* native_free_cb */
-static const jerry_object_native_info_t native_info =
-{
+static const jerry_object_native_info_t native_info = {
.free_cb = native_free_cb,
.number_of_references = 0,
.offset_of_references = 0,
diff --git a/tests/unit-ext/test-ext-handle-scope-root.c b/tests/unit-ext/test-ext-handle-scope-root.c
index f363ed12..cd282fd6 100644
--- a/tests/unit-ext/test-ext-handle-scope-root.c
+++ b/tests/unit-ext/test-ext-handle-scope-root.c
@@ -18,6 +18,7 @@
*/
#include "jerryscript.h"
+
#include "jerryscript-ext/handle-scope.h"
#include "test-common.h"
@@ -33,8 +34,7 @@ native_free_cb (void *native_p, /**< native pointer */
++native_free_cb_call_count;
} /* native_free_cb */
-static const jerry_object_native_info_t native_info =
-{
+static const jerry_object_native_info_t native_info = {
.free_cb = native_free_cb,
.number_of_references = 0,
.offset_of_references = 0,
diff --git a/tests/unit-ext/test-ext-handle-scope.c b/tests/unit-ext/test-ext-handle-scope.c
index 60225654..58381735 100644
--- a/tests/unit-ext/test-ext-handle-scope.c
+++ b/tests/unit-ext/test-ext-handle-scope.c
@@ -18,6 +18,7 @@
*/
#include "jerryscript.h"
+
#include "jerryscript-ext/handle-scope.h"
#include "test-common.h"
@@ -32,8 +33,7 @@ native_free_cb (void *native_p, /**< native pointer */
++native_free_cb_call_count;
} /* native_free_cb */
-static const jerry_object_native_info_t native_info =
-{
+static const jerry_object_native_info_t native_info = {
.free_cb = native_free_cb,
.number_of_references = 0,
.offset_of_references = 0,
diff --git a/tests/unit-ext/test-ext-method-register.c b/tests/unit-ext/test-ext-method-register.c
index 119417dc..d39c2892 100644
--- a/tests/unit-ext/test-ext-method-register.c
+++ b/tests/unit-ext/test-ext-method-register.c
@@ -17,12 +17,13 @@
* Unit test for jerry-ext/handler property registration
*/
+#include <string.h>
+
#include "jerryscript.h"
+
#include "jerryscript-ext/handler.h"
#include "test-common.h"
-#include <string.h>
-
static jerry_value_t
method_hello (const jerry_call_info_t *call_info_p, /**< call information */
const jerry_value_t jargv[], /**< arguments */
@@ -64,16 +65,11 @@ test_simple_registration (void)
jerry_value_t target_object = jerry_create_object ();
// Test simple registration
- jerryx_property_entry methods[] =
- {
- JERRYX_PROPERTY_FUNCTION ("hello", method_hello),
- JERRYX_PROPERTY_NUMBER ("my_number", 42.5),
- JERRYX_PROPERTY_STRING ("my_str", "super_str"),
- JERRYX_PROPERTY_STRING_SZ ("my_str_sz", "super_str", 6),
- JERRYX_PROPERTY_BOOLEAN ("my_bool", true),
- JERRYX_PROPERTY_BOOLEAN ("my_bool_false", false),
- JERRYX_PROPERTY_UNDEFINED ("my_non_value"),
- JERRYX_PROPERTY_LIST_END (),
+ jerryx_property_entry methods[] = {
+ JERRYX_PROPERTY_FUNCTION ("hello", method_hello), JERRYX_PROPERTY_NUMBER ("my_number", 42.5),
+ JERRYX_PROPERTY_STRING ("my_str", "super_str"), JERRYX_PROPERTY_STRING_SZ ("my_str_sz", "super_str", 6),
+ JERRYX_PROPERTY_BOOLEAN ("my_bool", true), JERRYX_PROPERTY_BOOLEAN ("my_bool_false", false),
+ JERRYX_PROPERTY_UNDEFINED ("my_non_value"), JERRYX_PROPERTY_LIST_END (),
};
jerryx_register_result register_result = jerryx_set_properties (target_object, methods);
@@ -196,8 +192,7 @@ test_error_single_function (void)
jerry_value_t target_object = jerry_create_object ();
freeze_property (target_object, target_prop);
- jerryx_property_entry methods[] =
- {
+ jerryx_property_entry methods[] = {
JERRYX_PROPERTY_FUNCTION (target_prop, method_hello), // This registration should fail
JERRYX_PROPERTY_LIST_END (),
};
@@ -228,8 +223,7 @@ test_error_multiple_functions (void)
jerry_value_t target_object = jerry_create_object ();
freeze_property (target_object, prop_err);
- jerryx_property_entry methods[] =
- {
+ jerryx_property_entry methods[] = {
JERRYX_PROPERTY_FUNCTION (prop_ok, method_hello), // This registration is ok
JERRYX_PROPERTY_FUNCTION (prop_err, method_hello), // This registration should fail
JERRYX_PROPERTY_FUNCTION (prop_not, method_hello), // This registration is not done
@@ -254,16 +248,12 @@ test_error_multiple_functions (void)
// Try calling the method
jerry_value_t prop_ok_func = jerry_get_property (target_object, prop_ok_val);
TEST_ASSERT (jerry_value_is_function (prop_ok_func) == true);
- jerry_value_t args[2] =
- {
+ jerry_value_t args[2] = {
jerry_create_number (22),
jerry_create_number (-3),
};
jerry_size_t args_cnt = sizeof (args) / sizeof (jerry_value_t);
- jerry_value_t func_result = jerry_call_function (prop_ok_func,
- jerry_create_undefined (),
- args,
- args_cnt);
+ jerry_value_t func_result = jerry_call_function (prop_ok_func, jerry_create_undefined (), args, args_cnt);
TEST_ASSERT (jerry_value_is_number (func_result) == true);
TEST_ASSERT ((uint32_t) jerry_get_number_value (func_result) == 2u);
jerry_release_value (func_result);
diff --git a/tests/unit-ext/test-ext-module-canonical.c b/tests/unit-ext/test-ext-module-canonical.c
index a6c3e812..07c00b03 100644
--- a/tests/unit-ext/test-ext-module-canonical.c
+++ b/tests/unit-ext/test-ext-module-canonical.c
@@ -16,11 +16,12 @@
#include <string.h>
#include "jerryscript.h"
-#include "test-common.h"
+
#include "jerryscript-ext/module.h"
+#include "test-common.h"
#define ACTUAL_NAME "alice"
-#define ALIAS_NAME "bob"
+#define ALIAS_NAME "bob"
static jerry_value_t
get_canonical_name (const jerry_value_t name)
@@ -60,11 +61,8 @@ resolve (const jerry_value_t canonical_name, jerry_value_t *result)
return false;
} /* resolve */
-static const jerryx_module_resolver_t canonical_test =
-{
- .get_canonical_name_p = get_canonical_name,
- .resolve_p = resolve
-};
+static const jerryx_module_resolver_t canonical_test = { .get_canonical_name_p = get_canonical_name,
+ .resolve_p = resolve };
#define TEST_VALUE 95.0
diff --git a/tests/unit-ext/test-ext-module-empty.c b/tests/unit-ext/test-ext-module-empty.c
index 0e316582..b9b0ad22 100644
--- a/tests/unit-ext/test-ext-module-empty.c
+++ b/tests/unit-ext/test-ext-module-empty.c
@@ -16,8 +16,9 @@
#include <string.h>
#include "jerryscript.h"
-#include "test-common.h"
+
#include "jerryscript-ext/module.h"
+#include "test-common.h"
int
main (int argc, char **argv)
diff --git a/tests/unit-math/test-math.c b/tests/unit-math/test-math.c
index 67e2e2c4..aa25a856 100644
--- a/tests/unit-math/test-math.c
+++ b/tests/unit-math/test-math.c
@@ -51,9 +51,12 @@ check_double (const char *expr, double computed, double expected)
computed_bits.value = computed;
expected_bits.value = expected;
- printf ("%s = 0x%08x%08x [expected=0x%08x%08x] ", expr,
- (unsigned int) computed_bits.bits32[1], (unsigned int) computed_bits.bits32[0],
- (unsigned int) expected_bits.bits32[1], (unsigned int) expected_bits.bits32[0]);
+ printf ("%s = 0x%08x%08x [expected=0x%08x%08x] ",
+ expr,
+ (unsigned int) computed_bits.bits32[1],
+ (unsigned int) computed_bits.bits32[0],
+ (unsigned int) expected_bits.bits32[1],
+ (unsigned int) expected_bits.bits32[0]);
bool result;
if (isnan (computed) && isnan (expected))