UNPKG

sku-pg

Version:

Skulpt is a Javascript implementation of Python 2.x. Python that runs in your browser!

40 lines (34 loc) 958 B
<!DOCTYPE html> <html> <!-- Copyright 2009 The Closure Library Authors. All Rights Reserved. Use of this source code is governed by an Apache 2.0 License. See the COPYING file for details. --> <!-- Author: pallosp@google.com (Peter Pallos) --> <head> <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>