blob: 2012ce98d3da483bca2beab5188fa9c71e90a132 (
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
|
<!DOCTYPE html>
<html>
<!--
Copyright 2009 The Closure Library Authors. All Rights Reserved.
Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<!--
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Closure Unit Tests - goog.testing.singleton</title>
<script src="../base.js"></script>
<script>
goog.require('goog.testing.asserts');
goog.require('goog.testing.jsunit');
goog.require('goog.testing.singleton');
</script>
</head>
<body>
<script>
function testGetInstance() {
function SingletonClass() {}
goog.addSingletonGetter(SingletonClass);
var s1 = SingletonClass.getInstance();
var s2 = SingletonClass.getInstance();
assertEquals('second getInstance call returns the same instance', s1, s2);
goog.testing.singleton.reset();
var s3 = SingletonClass.getInstance();
assertNotEquals('getInstance returns a new instance after reset', s1, s3);
}
</script>
</body>
</html>
|