| 1 |
// |reftest| skip-if(!Object.prototype.toSource) |
| 2 |
|
| 3 |
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ |
| 4 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
| 5 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 7 |
|
| 8 |
//----------------------------------------------------------------------------- |
| 9 |
var BUGNUMBER = 381304; |
| 10 |
var summary = 'getter/setter with keywords'; |
| 11 |
var actual = ''; |
| 12 |
var expect = ''; |
| 13 |
|
| 14 |
|
| 15 |
//----------------------------------------------------------------------------- |
| 16 |
test(); |
| 17 |
//----------------------------------------------------------------------------- |
| 18 |
|
| 19 |
function test() |
| 20 |
{ |
| 21 |
printBugNumber(BUGNUMBER); |
| 22 |
printStatus (summary); |
| 23 |
|
| 24 |
var obj; |
| 25 |
|
| 26 |
print('1'); |
| 27 |
|
| 28 |
obj = { |
| 29 |
set inn(value) {this.for = value;}, |
| 30 |
get inn() {return this.for;} |
| 31 |
}; |
| 32 |
|
| 33 |
expect = '({get inn() {return this.for;}, set inn(value) {this.for = value;}})'; |
| 34 |
actual = obj.toSource(); |
| 35 |
compareSource(expect, actual, summary + ': 1'); |
| 36 |
|
| 37 |
print('2'); |
| 38 |
|
| 39 |
obj = { |
| 40 |
set in(value) {this.for = value;}, |
| 41 |
get in() {return this.for;} |
| 42 |
}; |
| 43 |
|
| 44 |
expect = '({get in() {return this.for;}, set in(value) {this.for = value;}})'; |
| 45 |
actual = obj.toSource(); |
| 46 |
compareSource(expect, actual, summary + ': 2'); |
| 47 |
|
| 48 |
print('3'); |
| 49 |
|
| 50 |
obj = { |
| 51 |
set inn(value) {this.for = value;}, |
| 52 |
get in() {return this.for;} |
| 53 |
}; |
| 54 |
|
| 55 |
expect = '({set inn(value) {this.for = value;}, get in() {return this.for;}})'; |
| 56 |
actual = obj.toSource(); |
| 57 |
compareSource(expect, actual, summary + ': 4'); |
| 58 |
|
| 59 |
print('4'); |
| 60 |
|
| 61 |
obj = { |
| 62 |
set in(value) {this.for = value;}, |
| 63 |
get inn() {return this.for;} |
| 64 |
}; |
| 65 |
|
| 66 |
expect = '({set in(value) {this.for = value;}, get inn() {return this.for;}})'; |
| 67 |
actual = obj.toSource(); |
| 68 |
compareSource(expect, actual, summary + ': 5'); |
| 69 |
} |