sku-pg
Version:
Skulpt is a Javascript implementation of Python 2.x. Python that runs in your browser!
40 lines (34 loc) • 978 B
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>