MCPcopy Create free account
hub / github.com/dop251/goja / TestArrayAssignmentPatternEvalOrder

Function TestArrayAssignmentPatternEvalOrder

compiler_test.go:3970–4028  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3968}
3969
3970func TestArrayAssignmentPatternEvalOrder(t *testing.T) {
3971 const SCRIPT = `
3972 let trace = "";
3973
3974 let src_arr = {
3975 [Symbol.iterator]: function() {
3976 let done = false;
3977 return {
3978 next: function() {
3979 trace += "next,";
3980 if (!done) {
3981 done = true;
3982 return {value: 0};
3983 }
3984 return {done: true};
3985 },
3986 return: function() {
3987 trace += "return,";
3988 }
3989 }
3990 }
3991 }
3992
3993 function src() {
3994 trace += "src(),";
3995 return src_arr;
3996 }
3997
3998 let tgt = {
3999 get a() {
4000 trace += "get a,";
4001 return "a";
4002 },
4003 get b() {
4004 trace += "get b,";
4005 return "b";
4006 }
4007 }
4008
4009 function target() {
4010 trace += "target(),";
4011 return tgt;
4012 }
4013
4014 function default_a() {
4015 trace += "default a,";
4016 return "def_a";
4017 }
4018
4019 function default_b() {
4020 trace += "default b,";
4021 return "def_b";
4022 }
4023
4024 ([target().a = default_a(), target().b = default_b()] = src());
4025 trace;
4026 `
4027 testScript(SCRIPT, asciiString("src(),target(),next,target(),next,default b,"), t)

Callers

nothing calls this directly

Calls 2

testScriptFunction · 0.85
asciiStringTypeAlias · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…