Merge commit 'e92e27838aa14ec4' into 0.2

This commit is contained in:
Anna Sobiepanek 2010-12-19 15:59:32 -05:00
Родитель 331bf27f92 e92e27838a
Коммит 3319016739
2 изменённых файлов: 46 добавлений и 3 удалений

Просмотреть файл

@ -170,8 +170,9 @@
error: function( msg ) {
throw msg;
},
guid: function() {
return +new Date() + Math.floor(Math.random()*11);
guid: function( prefix ) {
Popcorn.guid.counter++;
return ( prefix ? prefix : '' ) + ( +new Date() + Popcorn.guid.counter );
},
sizeOf: function ( obj ) {
var size = 0;
@ -187,6 +188,9 @@
nop: function () {}
});
// Memoization property
Popcorn.guid.counter = 1;
// Simple Factory pattern to implement getters, setters and controllers
// as methods of the returned Popcorn instance. The immediately invoked function
// creates and returns an object of methods
@ -437,7 +441,7 @@
if ( track.natives ) {
// supports user defined track event id
track._id = !track.id ? track.natives.type + Popcorn.guid() : track.id;
track._id = !track.id ? Popcorn.guid( track.natives.type ) : track.id;
// Push track event ids into the history
obj.data.history.push( track._id );

Просмотреть файл

@ -56,6 +56,45 @@ test("Utility", function () {
});
test("guid", function () {
expect(6);
var count = 3,
guids = [],
temp;
for ( var i = 0; i < count; i++ ) {
temp = Popcorn.guid();
if ( i > 0 ) {
notEqual( temp, guids[ guids.length - 1 ], "Current guid does not equal last guid" );
} else {
ok( temp, "Popcorn.guid() returns value" );
}
guids.push(temp);
}
guids = [];
for ( var i = 0; i < count; i++ ) {
temp = Popcorn.guid( "pre" );
if ( i > 0 ) {
notEqual( temp, guids[ guids.length - 1 ], "Current guid does not equal last guid" );
} else {
ok( temp, "Popcorn.guid( 'pre' ) returns value" );
}
guids.push(temp);
}
});
test("Protected", function () {
expect(1);