summaryrefslogtreecommitdiff
path: root/js/src/tests/js1_8_1/extensions/regress-520572.js
blob: 581f4818f85f8d6c15dffd3c186644e211209be1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* -*- Mode: java; tab-width:8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/
 * Contributor: Blake Kaplan
 */

//-----------------------------------------------------------------------------
var BUGNUMBER = 520572;
var summary = 'watch should innerize the object being watched';
var actual = 0;
var expect = 2;


//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------

function test()
{
  enterFunc ('test');
  printBugNumber(BUGNUMBER);
  printStatus (summary);

  if ("evalcx" in this) {
      // shell
      let s = evalcx("split");
      s.n = 0;
      evalcx('this.watch("x", function(){ n++; }); this.x = 4; x = 6', s);
      actual = s.n;
      reportCompare(expect, actual, summary);
  } else {
      // browser
      this.watch('x', function(){ actual++; });
      this.x = 4;
      x = 6;
      reportCompare(expect, actual, summary);
  }

  exitFunc ('test');
}