| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
esid: sec-escape-string |
| 5 |
es6id: B.2.1.1 |
| 6 |
description: Observable operations from string coercion |
| 7 |
info: | |
| 8 |
1. Let string be ? ToString(string). |
| 9 |
---*/ |
| 10 |
|
| 11 |
var log, obj; |
| 12 |
|
| 13 |
log = ''; |
| 14 |
obj = { |
| 15 |
toString: function() { |
| 16 |
log += 'toString'; |
| 17 |
}, |
| 18 |
valueOf: function() { |
| 19 |
log += 'valueOf'; |
| 20 |
} |
| 21 |
}; |
| 22 |
|
| 23 |
escape(obj); |
| 24 |
|
| 25 |
assert.sameValue(log, 'toString'); |
| 26 |
|
| 27 |
log = ''; |
| 28 |
obj = { |
| 29 |
toString: null, |
| 30 |
valueOf: function() { |
| 31 |
log += 'valueOf'; |
| 32 |
} |
| 33 |
}; |
| 34 |
|
| 35 |
escape(obj); |
| 36 |
|
| 37 |
assert.sameValue(log, 'valueOf'); |
| 38 |
|
| 39 |
log = ''; |
| 40 |
obj = { |
| 41 |
toString: function() { |
| 42 |
log += 'toString'; |
| 43 |
return {}; |
| 44 |
}, |
| 45 |
valueOf: function() { |
| 46 |
log += 'valueOf'; |
| 47 |
} |
| 48 |
}; |
| 49 |
|
| 50 |
escape(obj); |
| 51 |
|
| 52 |
assert.sameValue(log, 'toStringvalueOf'); |