add test for multiple declaration
This commit is contained in:
48
vm_suite.ce
48
vm_suite.ce
@@ -3995,6 +3995,37 @@ run("shorthand property with null", function() {
|
|||||||
assert_eq(obj.x, null, "null shorthand")
|
assert_eq(obj.x, null, "null shorthand")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
run("shorthand property many", function() {
|
||||||
|
var a = 1
|
||||||
|
var b = 2
|
||||||
|
var c = 3
|
||||||
|
var d = 4
|
||||||
|
var e = 5
|
||||||
|
var f = 6
|
||||||
|
var g = 7
|
||||||
|
var h = 8
|
||||||
|
var i = 9
|
||||||
|
var j = 10
|
||||||
|
var obj = {a, b, c, d, e, f, g, h, i, j}
|
||||||
|
assert_eq(obj.a, 1, "a")
|
||||||
|
assert_eq(obj.e, 5, "e")
|
||||||
|
assert_eq(obj.j, 10, "j")
|
||||||
|
})
|
||||||
|
|
||||||
|
run("shorthand property with method", function() {
|
||||||
|
var z = 300
|
||||||
|
var obj = {z, double(n) { return n * 2 }}
|
||||||
|
assert_eq(obj.z, 300, "shorthand z")
|
||||||
|
assert_eq(obj.double(5), 10, "method double")
|
||||||
|
})
|
||||||
|
|
||||||
|
run("shorthand property is a snapshot", function() {
|
||||||
|
var val = "original"
|
||||||
|
var obj = {val}
|
||||||
|
val = "changed"
|
||||||
|
assert_eq(obj.val, "original", "object keeps original")
|
||||||
|
})
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// SHARED CLOSURES
|
// SHARED CLOSURES
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -4149,6 +4180,23 @@ run("template literal nested calls", function() {
|
|||||||
assert_eq(`result: ${double(5)}`, "result: 10", "fn call in template")
|
assert_eq(`result: ${double(5)}`, "result: 10", "fn call in template")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// COMMA-SEPARATED DECLARATIONS
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
run("comma separated var declarations", function() {
|
||||||
|
var a = 1, b = 2, c = 3
|
||||||
|
assert_eq(a, 1, "first")
|
||||||
|
assert_eq(b, 2, "second")
|
||||||
|
assert_eq(c, 3, "third")
|
||||||
|
})
|
||||||
|
|
||||||
|
run("comma separated def declarations", function() {
|
||||||
|
def x = 10, y = 20
|
||||||
|
assert_eq(x, 10, "def first")
|
||||||
|
assert_eq(y, 20, "def second")
|
||||||
|
})
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// DEF CONSTANTS
|
// DEF CONSTANTS
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user