Debian Codegraph @

rhino/testsrc/tests/js1_5/GetSet/getset-002.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 var gTestfile = 'getset-002.js';
8
9 var t = {
10 _y: "<initial y>",
11
12 y getter: function get_y ()
13 {
14 var rv;
15 if (typeof this._y == "string")
16 rv = "got " + this._y;
17 else
18 rv = this._y;
19
20 return rv;
21 },
22
23 y setter: function set_y (newVal)
24 {
25 this._y = newVal;
26 }
27 }
28
29
30 test(t);
31
32 function test(t)
33 {
34 enterFunc ("test");
35
36 printStatus ("Basic Getter/ Setter test (object literal notation)");
37
38 reportCompare ("<initial y>", t._y, "y prototype check");
39
40 reportCompare ("got <initial y>", t.y, "y getter, before set");
41
42 t.y = "new y";
43 reportCompare ("got new y", t.y, "y getter, after set");
44
45 t.y = 2;
46 reportCompare (2, t.y, "y getter, after numeric set");
47
48 var d = new Date();
49 t.y = d;
50 reportCompare (d, t.y, "y getter, after date set");
51
52 }