1425bb815Sopenharmony_ci/* Copyright JS Foundation and other contributors, http://js.foundation 2425bb815Sopenharmony_ci * 3425bb815Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4425bb815Sopenharmony_ci * you may not use this file except in compliance with the License. 5425bb815Sopenharmony_ci * You may obtain a copy of the License at 6425bb815Sopenharmony_ci * 7425bb815Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8425bb815Sopenharmony_ci * 9425bb815Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10425bb815Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS 11425bb815Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12425bb815Sopenharmony_ci * See the License for the specific language governing permissions and 13425bb815Sopenharmony_ci * limitations under the License. 14425bb815Sopenharmony_ci */ 15425bb815Sopenharmony_ci 16425bb815Sopenharmony_ci#include "jerryscript.h" 17425bb815Sopenharmony_ci#include "jerryscript-port.h" 18425bb815Sopenharmony_ci#include "jerryscript-port-default.h" 19425bb815Sopenharmony_ci#include "test-common.h" 20425bb815Sopenharmony_ci#include <gtest/gtest.h> 21425bb815Sopenharmony_ci 22425bb815Sopenharmony_ci#define T(op, lhs, rhs, res) \ 23425bb815Sopenharmony_ci { op, lhs, rhs, res } 24425bb815Sopenharmony_ci 25425bb815Sopenharmony_citypedef struct 26425bb815Sopenharmony_ci{ 27425bb815Sopenharmony_ci jerry_binary_operation_t op; 28425bb815Sopenharmony_ci jerry_value_t lhs; 29425bb815Sopenharmony_ci jerry_value_t rhs; 30425bb815Sopenharmony_ci bool expected; 31425bb815Sopenharmony_ci} test_entry_t; 32425bb815Sopenharmony_ci 33425bb815Sopenharmony_ciclass ApiBinaryOperationsComparisonsTest : public testing::Test{ 34425bb815Sopenharmony_cipublic: 35425bb815Sopenharmony_ci static void SetUpTestCase() 36425bb815Sopenharmony_ci { 37425bb815Sopenharmony_ci GTEST_LOG_(INFO) << "ApiBinaryOperationsComparisonsTest SetUpTestCase"; 38425bb815Sopenharmony_ci } 39425bb815Sopenharmony_ci 40425bb815Sopenharmony_ci static void TearDownTestCase() 41425bb815Sopenharmony_ci { 42425bb815Sopenharmony_ci GTEST_LOG_(INFO) << "ApiBinaryOperationsComparisonsTest TearDownTestCase"; 43425bb815Sopenharmony_ci } 44425bb815Sopenharmony_ci 45425bb815Sopenharmony_ci void SetUp() override {} 46425bb815Sopenharmony_ci void TearDown() override {} 47425bb815Sopenharmony_ci 48425bb815Sopenharmony_ci}; 49425bb815Sopenharmony_ci 50425bb815Sopenharmony_cistatic constexpr size_t JERRY_SCRIPT_MEM_SIZE = 50 * 1024 * 1024; 51425bb815Sopenharmony_cistatic void* context_alloc_fn(size_t size, void* cb_data) 52425bb815Sopenharmony_ci{ 53425bb815Sopenharmony_ci (void)cb_data; 54425bb815Sopenharmony_ci size_t newSize = size > JERRY_SCRIPT_MEM_SIZE ? JERRY_SCRIPT_MEM_SIZE : size; 55425bb815Sopenharmony_ci return malloc(newSize); 56425bb815Sopenharmony_ci} 57425bb815Sopenharmony_ciHWTEST_F(ApiBinaryOperationsComparisonsTest, Test001, testing::ext::TestSize.Level1) 58425bb815Sopenharmony_ci{ 59425bb815Sopenharmony_ci jerry_context_t *ctx_p = jerry_create_context (1024, context_alloc_fn, NULL); 60425bb815Sopenharmony_ci jerry_port_default_set_current_context (ctx_p); 61425bb815Sopenharmony_ci TEST_INIT (); 62425bb815Sopenharmony_ci 63425bb815Sopenharmony_ci jerry_init (JERRY_INIT_EMPTY); 64425bb815Sopenharmony_ci 65425bb815Sopenharmony_ci jerry_value_t obj1 = jerry_eval ((const jerry_char_t *) "o={x:1};o", 9, JERRY_PARSE_NO_OPTS); 66425bb815Sopenharmony_ci jerry_value_t obj2 = jerry_eval ((const jerry_char_t *) "o={x:1};o", 9, JERRY_PARSE_NO_OPTS); 67425bb815Sopenharmony_ci jerry_value_t err1 = jerry_create_error (JERRY_ERROR_SYNTAX, (const jerry_char_t *) "error"); 68425bb815Sopenharmony_ci 69425bb815Sopenharmony_ci test_entry_t tests[] = 70425bb815Sopenharmony_ci { 71425bb815Sopenharmony_ci /* Testing strict equal comparison */ 72425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_number (5.0), jerry_create_number (5.0), true), 73425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_number (3.1), jerry_create_number (10), false), 74425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_number (3.1), jerry_create_undefined (), false), 75425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_number (3.1), jerry_create_boolean (true), false), 76425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, 77425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 78425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 79425bb815Sopenharmony_ci true), 80425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, 81425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 82425bb815Sopenharmony_ci jerry_create_undefined (), 83425bb815Sopenharmony_ci false), 84425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, 85425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 86425bb815Sopenharmony_ci jerry_create_null (), 87425bb815Sopenharmony_ci false), 88425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, 89425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 90425bb815Sopenharmony_ci jerry_create_number (5.0), 91425bb815Sopenharmony_ci false), 92425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_undefined (), jerry_create_undefined (), true), 93425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_undefined (), jerry_create_null (), false), 94425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_null (), jerry_create_null (), true), 95425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_boolean (true), jerry_create_boolean (true), true), 96425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_boolean (true), jerry_create_boolean (false), false), 97425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_boolean (false), jerry_create_boolean (true), false), 98425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_boolean (false), jerry_create_boolean (false), true), 99425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_acquire_value (obj1), true), 100425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_acquire_value (obj2), false), 101425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj2), jerry_acquire_value (obj1), false), 102425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_create_null (), false), 103425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_create_undefined (), false), 104425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_create_boolean (true), false), 105425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_create_boolean (false), false), 106425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_create_number (5.0), false), 107425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, 108425bb815Sopenharmony_ci jerry_acquire_value (obj1), 109425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 110425bb815Sopenharmony_ci false), 111425bb815Sopenharmony_ci 112425bb815Sopenharmony_ci /* Testing equal comparison */ 113425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_create_number (5.0), jerry_create_number (5.0), true), 114425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_create_number (3.1), jerry_create_number (10), false), 115425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_create_number (3.1), jerry_create_undefined (), false), 116425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_create_number (3.1), jerry_create_boolean (true), false), 117425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, 118425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 119425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 120425bb815Sopenharmony_ci true), 121425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, 122425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 123425bb815Sopenharmony_ci jerry_create_undefined (), 124425bb815Sopenharmony_ci false), 125425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, 126425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 127425bb815Sopenharmony_ci jerry_create_null (), 128425bb815Sopenharmony_ci false), 129425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, 130425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 131425bb815Sopenharmony_ci jerry_create_number (5.0), 132425bb815Sopenharmony_ci false), 133425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_create_undefined (), jerry_create_undefined (), true), 134425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_create_undefined (), jerry_create_null (), true), 135425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_create_null (), jerry_create_null (), true), 136425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_create_boolean (true), jerry_create_boolean (true), true), 137425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_create_boolean (true), jerry_create_boolean (false), false), 138425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_create_boolean (false), jerry_create_boolean (true), false), 139425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_create_boolean (false), jerry_create_boolean (false), true), 140425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_acquire_value (obj1), true), 141425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_acquire_value (obj2), false), 142425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj2), jerry_acquire_value (obj1), false), 143425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_create_null (), false), 144425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_create_undefined (), false), 145425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_create_boolean (true), false), 146425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_create_boolean (false), false), 147425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_create_number (5.0), false), 148425bb815Sopenharmony_ci T (JERRY_BIN_OP_EQUAL, 149425bb815Sopenharmony_ci jerry_acquire_value (obj1), 150425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "example string"), 151425bb815Sopenharmony_ci false), 152425bb815Sopenharmony_ci 153425bb815Sopenharmony_ci /* Testing less comparison */ 154425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, jerry_create_number (5.0), jerry_create_number (5.0), false), 155425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, jerry_create_number (3.1), jerry_create_number (10), true), 156425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, jerry_create_number (3.1), jerry_create_undefined (), false), 157425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, jerry_create_number (3.1), jerry_create_boolean (true), false), 158425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, 159425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 160425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "2"), 161425bb815Sopenharmony_ci true), 162425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, 163425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 164425bb815Sopenharmony_ci jerry_create_undefined (), 165425bb815Sopenharmony_ci false), 166425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, 167425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 168425bb815Sopenharmony_ci jerry_create_null (), 169425bb815Sopenharmony_ci false), 170425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, 171425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 172425bb815Sopenharmony_ci jerry_create_number (5.0), 173425bb815Sopenharmony_ci true), 174425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, jerry_create_undefined (), jerry_create_undefined (), false), 175425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, jerry_create_undefined (), jerry_create_null (), false), 176425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, jerry_create_null (), jerry_create_null (), false), 177425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, jerry_create_boolean (true), jerry_create_boolean (true), false), 178425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, jerry_create_boolean (true), jerry_create_boolean (false), false), 179425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, jerry_create_boolean (false), jerry_create_boolean (true), true), 180425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS, jerry_create_boolean (false), jerry_create_boolean (false), false), 181425bb815Sopenharmony_ci 182425bb815Sopenharmony_ci /* Testing less or equal comparison */ 183425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_number (5.0), jerry_create_number (5.0), true), 184425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_number (5.1), jerry_create_number (5.0), false), 185425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_number (3.1), jerry_create_number (10), true), 186425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_number (3.1), jerry_create_undefined (), false), 187425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_number (3.1), jerry_create_boolean (true), false), 188425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, 189425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 190425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "2"), 191425bb815Sopenharmony_ci true), 192425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, 193425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 194425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 195425bb815Sopenharmony_ci true), 196425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, 197425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 198425bb815Sopenharmony_ci jerry_create_undefined (), 199425bb815Sopenharmony_ci false), 200425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, 201425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 202425bb815Sopenharmony_ci jerry_create_null (), 203425bb815Sopenharmony_ci false), 204425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, 205425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 206425bb815Sopenharmony_ci jerry_create_number (5.0), 207425bb815Sopenharmony_ci true), 208425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, 209425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "5.0"), 210425bb815Sopenharmony_ci jerry_create_number (5.0), 211425bb815Sopenharmony_ci true), 212425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_undefined (), jerry_create_undefined (), false), 213425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_undefined (), jerry_create_null (), false), 214425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_null (), jerry_create_null (), true), 215425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_boolean (true), jerry_create_boolean (true), true), 216425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_boolean (true), jerry_create_boolean (false), false), 217425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_boolean (false), jerry_create_boolean (true), true), 218425bb815Sopenharmony_ci T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_boolean (false), jerry_create_boolean (false), true), 219425bb815Sopenharmony_ci 220425bb815Sopenharmony_ci /* Testing greater comparison */ 221425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, jerry_create_number (5.0), jerry_create_number (5.0), false), 222425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, jerry_create_number (10), jerry_create_number (3.1), true), 223425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, jerry_create_number (3.1), jerry_create_undefined (), false), 224425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, jerry_create_number (3.1), jerry_create_boolean (true), true), 225425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, 226425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "2"), 227425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 228425bb815Sopenharmony_ci true), 229425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, 230425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 231425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "2"), 232425bb815Sopenharmony_ci false), 233425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, 234425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 235425bb815Sopenharmony_ci jerry_create_undefined (), 236425bb815Sopenharmony_ci false), 237425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, 238425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 239425bb815Sopenharmony_ci jerry_create_null (), 240425bb815Sopenharmony_ci true), 241425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, 242425bb815Sopenharmony_ci jerry_create_number (5.0), 243425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 244425bb815Sopenharmony_ci true), 245425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, jerry_create_undefined (), jerry_create_undefined (), false), 246425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, jerry_create_undefined (), jerry_create_null (), false), 247425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, jerry_create_null (), jerry_create_null (), false), 248425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, jerry_create_boolean (true), jerry_create_boolean (true), false), 249425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, jerry_create_boolean (true), jerry_create_boolean (false), true), 250425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, jerry_create_boolean (false), jerry_create_boolean (true), false), 251425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER, jerry_create_boolean (false), jerry_create_boolean (false), false), 252425bb815Sopenharmony_ci 253425bb815Sopenharmony_ci /* Testing greater or equal comparison */ 254425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_number (5.0), jerry_create_number (5.0), true), 255425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_number (5.0), jerry_create_number (5.1), false), 256425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_number (10), jerry_create_number (3.1), true), 257425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_number (3.1), jerry_create_undefined (), false), 258425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_number (3.1), jerry_create_boolean (true), true), 259425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, 260425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "2"), 261425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 262425bb815Sopenharmony_ci true), 263425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, 264425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 265425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 266425bb815Sopenharmony_ci true), 267425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, 268425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 269425bb815Sopenharmony_ci jerry_create_undefined (), 270425bb815Sopenharmony_ci false), 271425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, 272425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 273425bb815Sopenharmony_ci jerry_create_null (), 274425bb815Sopenharmony_ci true), 275425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, 276425bb815Sopenharmony_ci jerry_create_number (5.0), 277425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "1"), 278425bb815Sopenharmony_ci true), 279425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, 280425bb815Sopenharmony_ci jerry_create_string ((const jerry_char_t *) "5.0"), 281425bb815Sopenharmony_ci jerry_create_number (5.0), 282425bb815Sopenharmony_ci true), 283425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_undefined (), jerry_create_undefined (), false), 284425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_undefined (), jerry_create_null (), false), 285425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_null (), jerry_create_null (), true), 286425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_boolean (true), jerry_create_boolean (true), true), 287425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_boolean (true), jerry_create_boolean (false), true), 288425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_boolean (false), jerry_create_boolean (true), false), 289425bb815Sopenharmony_ci T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_boolean (false), jerry_create_boolean (false), true), 290425bb815Sopenharmony_ci }; 291425bb815Sopenharmony_ci 292425bb815Sopenharmony_ci for (uint32_t idx = 0; idx < sizeof (tests) / sizeof (test_entry_t); idx++) 293425bb815Sopenharmony_ci { 294425bb815Sopenharmony_ci jerry_value_t result = jerry_binary_operation (tests[idx].op, tests[idx].lhs, tests[idx].rhs); 295425bb815Sopenharmony_ci TEST_ASSERT (!jerry_value_is_error (result)); 296425bb815Sopenharmony_ci TEST_ASSERT (jerry_get_boolean_value (result) == tests[idx].expected); 297425bb815Sopenharmony_ci jerry_release_value (tests[idx].lhs); 298425bb815Sopenharmony_ci jerry_release_value (tests[idx].rhs); 299425bb815Sopenharmony_ci jerry_release_value (result); 300425bb815Sopenharmony_ci } 301425bb815Sopenharmony_ci 302425bb815Sopenharmony_ci test_entry_t error_tests[] = 303425bb815Sopenharmony_ci { 304425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (err1), jerry_acquire_value (err1), true), 305425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (err1), jerry_create_undefined (), true), 306425bb815Sopenharmony_ci T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_undefined (), jerry_acquire_value (err1), true), 307425bb815Sopenharmony_ci }; 308425bb815Sopenharmony_ci 309425bb815Sopenharmony_ci for (uint32_t idx = 0; idx < sizeof (error_tests) / sizeof (test_entry_t); idx++) 310425bb815Sopenharmony_ci { 311425bb815Sopenharmony_ci jerry_value_t result = jerry_binary_operation (tests[idx].op, error_tests[idx].lhs, error_tests[idx].rhs); 312425bb815Sopenharmony_ci TEST_ASSERT (jerry_value_is_error (result) == error_tests[idx].expected); 313425bb815Sopenharmony_ci jerry_release_value (error_tests[idx].lhs); 314425bb815Sopenharmony_ci jerry_release_value (error_tests[idx].rhs); 315425bb815Sopenharmony_ci jerry_release_value (result); 316425bb815Sopenharmony_ci } 317425bb815Sopenharmony_ci 318425bb815Sopenharmony_ci jerry_release_value (obj1); 319425bb815Sopenharmony_ci jerry_release_value (obj2); 320425bb815Sopenharmony_ci jerry_release_value (err1); 321425bb815Sopenharmony_ci 322425bb815Sopenharmony_ci jerry_cleanup (); 323425bb815Sopenharmony_ci free (ctx_p); 324425bb815Sopenharmony_ci} 325