Skip to content
Snippets Groups Projects
Commit c1e1c56d authored by André Bargull's avatar André Bargull
Browse files

Increment/Decrement with property accessor expression

The increment/decrement operator evaluates its operand expression once. When
the operand expression is a property accessor, RequireObjectCoercible
and ToPropertyKey are called on the property accessor in the correct order.
parent cd538694
No related branches found
No related tags found
No related merge requests found
Showing
with 336 additions and 0 deletions
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator x-- evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. base is the null value.
---*/
function DummyError() { }
assert.throws(DummyError, function() {
var base = null;
var prop = function() {
throw new DummyError();
};
base[prop()]--;
});
assert.throws(TypeError, function() {
var base = null;
var prop = {
toString: function() {
$ERROR("property key evaluated");
}
};
base[prop]--;
});
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator x-- evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. base is the undefined value.
---*/
function DummyError() { }
assert.throws(DummyError, function() {
var base = undefined;
var prop = function() {
throw new DummyError();
};
base[prop()]--;
});
assert.throws(TypeError, function() {
var base = undefined;
var prop = {
toString: function() {
$ERROR("property key evaluated");
}
};
base[prop]--;
});
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator x-- evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. ToPropertyKey(prop) is not called multiple
times.
---*/
var propKeyEvaluated = false;
var base = {};
var prop = {
toString: function() {
assert(!propKeyEvaluated);
propKeyEvaluated = true;
return 1;
}
};
base[prop]--;
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator x++ evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. base is the null value.
---*/
function DummyError() { }
assert.throws(DummyError, function() {
var base = null;
var prop = function() {
throw new DummyError();
};
base[prop()]++;
});
assert.throws(TypeError, function() {
var base = null;
var prop = {
toString: function() {
$ERROR("property key evaluated");
}
};
base[prop]++;
});
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator x++ evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. base is the undefined value.
---*/
function DummyError() { }
assert.throws(DummyError, function() {
var base = undefined;
var prop = function() {
throw new DummyError();
};
base[prop()]++;
});
assert.throws(TypeError, function() {
var base = undefined;
var prop = {
toString: function() {
$ERROR("property key evaluated");
}
};
base[prop]++;
});
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator x++ evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. ToPropertyKey(prop) is not called multiple
times.
---*/
var propKeyEvaluated = false;
var base = {};
var prop = {
toString: function() {
assert(!propKeyEvaluated);
propKeyEvaluated = true;
return 1;
}
};
base[prop]++;
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator --x evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. base is the null value.
---*/
function DummyError() { }
assert.throws(DummyError, function() {
var base = null;
var prop = function() {
throw new DummyError();
};
--base[prop()];
});
assert.throws(TypeError, function() {
var base = null;
var prop = {
toString: function() {
$ERROR("property key evaluated");
}
};
--base[prop];
});
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator --x evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. base is the undefined value.
---*/
function DummyError() { }
assert.throws(DummyError, function() {
var base = undefined;
var prop = function() {
throw new DummyError();
};
--base[prop()];
});
assert.throws(TypeError, function() {
var base = undefined;
var prop = {
toString: function() {
$ERROR("property key evaluated");
}
};
--base[prop];
});
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator --x evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. ToPropertyKey(prop) is not called multiple
times.
---*/
var propKeyEvaluated = false;
var base = {};
var prop = {
toString: function() {
assert(!propKeyEvaluated);
propKeyEvaluated = true;
return 1;
}
};
--base[prop];
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator ++x evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. base is the null value.
---*/
function DummyError() { }
assert.throws(DummyError, function() {
var base = null;
var prop = function() {
throw new DummyError();
};
++base[prop()];
});
assert.throws(TypeError, function() {
var base = null;
var prop = {
toString: function() {
$ERROR("property key evaluated");
}
};
++base[prop];
});
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator ++x evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. base is the undefined value.
---*/
function DummyError() { }
assert.throws(DummyError, function() {
var base = undefined;
var prop = function() {
throw new DummyError();
};
++base[prop()];
});
assert.throws(TypeError, function() {
var base = undefined;
var prop = {
toString: function() {
$ERROR("property key evaluated");
}
};
++base[prop];
});
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Operator ++x evaluates its reference expression once.
description: >
The operand expression is evaluated exactly once. Operand expression is
MemberExpression: base[prop]. ToPropertyKey(prop) is not called multiple
times.
---*/
var propKeyEvaluated = false;
var base = {};
var prop = {
toString: function() {
assert(!propKeyEvaluated);
propKeyEvaluated = true;
return 1;
}
};
++base[prop];
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment