/*
* String.fromUTF8(start[, end]).
+ * The method converts an UTF-8 encoded byte string to an Unicode string.
*/
static njs_ret_t
/*
* String.toUTF8(start[, end]).
+ * The method serializes Unicode string to an UTF-8 encoded byte string.
*/
static njs_ret_t
/*
* String.fromBytes(start[, end]).
+ * The method converts a byte string to an Unicode string.
*/
static njs_ret_t
/*
* String.toBytes(start[, end]).
+ * The method serializes an Unicode string to a byte string.
+ * The method returns null if a character larger than 255 is
+ * encountered in the Unicode string.
*/
static njs_ret_t
* 3) if the length is less than NJS_STRING_MAP_OFFSET.
*
* The current implementation does not support Unicode surrogate pairs.
- * If offset in map points to surrogate pair, it the previous offset
+ * If offset in map points to surrogate pair then the previous offset
* should be used and so on until start of the string.
*/
const njs_value_t njs_string_string = njs_string("string");
const njs_value_t njs_string_object = njs_string("object");
const njs_value_t njs_string_function = njs_string("function");
-const njs_value_t njs_string_native = njs_string("[native code]");
const njs_value_t njs_exception_syntax_error = njs_string("SyntaxError");
const njs_value_t njs_exception_reference_error = njs_string("ReferenceError");
#define NJS_APPLIED NXT_DONE
-/* The order of the enum is used in njs_vmcode_typeof() */
+/*
+ * The order of the enum is used in njs_vmcode_typeof()
+ * and njs_object_prototype_to_string().
+ */
typedef enum {
NJS_NULL = 0x00,
{ nxt_string("'3' -+-+-+ '1' + '1' / '3' * '6' + '2'"),
nxt_string("42") },
+ { nxt_string("((+!![])+(+!![])+(+!![])+(+!![])+[])+((+!![])+(+!![])+[])"),
+ nxt_string("42") },
+
+ { nxt_string("1+[[]+[]]-[]+[[]-[]]-1"),
+ nxt_string("9") },
+
+ { nxt_string("[[]+[]]-[]+[[]-[]]"),
+ nxt_string("00") },
+
{ nxt_string("'true' == true"),
nxt_string("false") },
{ nxt_string("Function.constructor === Function"),
nxt_string("true") },
+ { nxt_string("function f() {} f.__proto__ === Function.prototype"),
+ nxt_string("true") },
+
{ nxt_string("RegExp()"),
nxt_string("/(?:)/") },
{ nxt_string("RegExp.constructor === Function"),
nxt_string("true") },
+ { nxt_string("/./.__proto__ === RegExp.prototype"),
+ nxt_string("true") },
+
{ nxt_string("Object.prototype.toString.call()"),
nxt_string("[object Undefined]") },
static nxt_int_t
lvlhsh_unit_test(nxt_uint_t n)
{
- uintptr_t key;
+ uintptr_t key;
nxt_uint_t i;
nxt_lvlhsh_t lh;
nxt_lvlhsh_each_t lhe;
nxt_mem_cache_pool_t *pool;
- const size_t min_chunk_size = 32;
- const size_t page_size = 1024;
- const size_t page_alignment = 128;
- const size_t cluster_size = 4096;
+ const size_t min_chunk_size = 32;
+ const size_t page_size = 1024;
+ const size_t page_alignment = 128;
+ const size_t cluster_size = 4096;
pool = nxt_mem_cache_pool_create(&mem_cache_pool_proto, NULL, NULL,
cluster_size, page_alignment,
typedef struct {
NXT_RBTREE_NODE (node);
- uint32_t key;
+ uint32_t key;
} nxt_rbtree_test_t;
static nxt_int_t
rbtree_unit_test(nxt_uint_t n)
{
- void *mark;
- uint32_t key, *keys;
+ void *mark;
+ uint32_t key, *keys;
nxt_uint_t i;
nxt_rbtree_t tree;
nxt_rbtree_node_t *node;
u_char *p, utf8[4];
size_t size;
uint32_t u, d;
- nxt_uint_t i;
+ nxt_uint_t i;
const u_char *pp;
pp = overlong;
size_t len;
int32_t n;
uint32_t u, d;
- nxt_uint_t i, k, l, m;
+ nxt_uint_t i, k, l, m;
const u_char *pp;
printf("utf8 unit test started\n");
}
n = nxt_utf8_casecmp((u_char *) "ABC АБВ ΑΒΓ",
- (u_char *) "abc абв αβγ",
- sizeof("ABC АБВ ΑΒΓ") - 1,
- sizeof("abc абв αβγ") - 1);
+ (u_char *) "abc абв αβγ",
+ sizeof("ABC АБВ ΑΒΓ") - 1,
+ sizeof("abc абв αβγ") - 1);
if (n != 0) {
printf("nxt_utf8_casecmp() failed\n");