Merge pull request #275 from anba/increment-reference

Increment/Decrement with property accessor expression
This commit is contained in:
Brian Terlson 2015-06-02 19:09:33 -05:00
commit f41d108840
12 changed files with 336 additions and 0 deletions

View File

@ -0,0 +1,31 @@
// 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]--;
});

View File

@ -0,0 +1,31 @@
// 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]--;
});

View File

@ -0,0 +1,22 @@
// 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]--;

View File

@ -0,0 +1,31 @@
// 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]++;
});

View File

@ -0,0 +1,31 @@
// 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]++;
});

View File

@ -0,0 +1,22 @@
// 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]++;

View File

@ -0,0 +1,31 @@
// 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];
});

View File

@ -0,0 +1,31 @@
// 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];
});

View File

@ -0,0 +1,22 @@
// 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];

View File

@ -0,0 +1,31 @@
// 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];
});

View File

@ -0,0 +1,31 @@
// 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];
});

View File

@ -0,0 +1,22 @@
// 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];