Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F9916074
bc_compile_test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
bc_compile_test.js
View Options
// Test bytecode compiler expression parsing
// This tests bc_compile() which is called from C
// Simple arithmetic
let
x
=
1
+
2
*
3
;
console
.
log
(
"1 + 2 * 3 ="
,
x
);
// 7
// Unary operators
let
y
=
-
5
;
let
z
=
!
true
;
console
.
log
(
"-5 ="
,
y
,
"!true ="
,
z
);
// Comparison
let
cmp
=
5
>
3
;
console
.
log
(
"5 > 3 ="
,
cmp
);
// Ternary
let
tern
=
true
?
"yes"
:
"no"
;
console
.
log
(
"true ? 'yes' : 'no' ="
,
tern
);
// Short-circuit
let
or_result
=
false
||
"default"
;
let
and_result
=
true
&&
"value"
;
console
.
log
(
"false || 'default' ="
,
or_result
);
console
.
log
(
"true && 'value' ="
,
and_result
);
// Object literal
let
obj
=
{
a
:
1
,
b
:
2
};
console
.
log
(
"obj.a ="
,
obj
.
a
,
"obj.b ="
,
obj
.
b
);
// Array literal
let
arr
=
[
1
,
2
,
3
];
console
.
log
(
"arr[0] ="
,
arr
[
0
],
"arr.length ="
,
arr
.
length
);
// Function call
console
.
log
(
"Math.max(1, 5, 3) ="
,
Math
.
max
(
1
,
5
,
3
));
// Member access
let
str
=
"hello"
;
console
.
log
(
"'hello'.length ="
,
str
.
length
);
// Nullish coalescing
let
nullish
=
null
??
"fallback"
;
console
.
log
(
"null ?? 'fallback' ="
,
nullish
);
// Optional chaining
let
maybe
=
{
nested
:
{
value
:
42
}
};
console
.
log
(
"maybe?.nested?.value ="
,
maybe
?
.
nested
?
.
value
);
console
.
log
(
"maybe?.missing?.value ="
,
maybe
?
.
missing
?
.
value
);
console
.
log
(
"\nAll expression tests passed!"
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Aug 1, 7:50 PM (20 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
603679
Default Alt Text
bc_compile_test.js (1 KB)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment