Changeset 215
- Timestamp:
- 06/08/05 05:24:39 (3 years ago)
- Location:
- branches/simplest-thing
- Files:
-
- 2 modified
-
lib/fm/gameobject.rb (modified) (5 diffs)
-
tests/gameobject.tests.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/simplest-thing/lib/fm/gameobject.rb
r204 r215 24 24 require 'digest/md5' 25 25 require 'logger' 26 require 'sync' 26 27 27 28 require 'fm/mixins' … … 42 43 # SVN Id 43 44 SVNId = %q$Id$ 44 45 # SVN URL46 SVNURL = %q$URL$47 45 48 46 # The total number of "attribution" points for this object. … … 164 162 super() 165 163 166 # Add unique ID and rev164 # Add unique ID, rev, and mutex 167 165 @id = self.class::makeObjectId( self ) 168 166 @rev = self.class::rev 167 @mutex = Sync::new 169 168 170 169 # Call setters for named arguments … … 175 174 176 175 177 ### Copy initializer -- generate a unique id for cloned objects.176 ### Copy initializer -- generate a unique id and mutex for cloned objects. 178 177 def initialize_copy( original ) 179 178 super 180 179 @id = self.class::makeObjectId( self ) 180 @mutex = Sync::new 181 181 self.log.debug "Cloned #{self.class.name} #{original.id}." 182 182 end … … 193 193 # the time of its creation or last upgrade. 194 194 attr_reader :rev 195 196 # The Sync mutex for this object 197 attr_reader :mutex 198 195 199 196 200 -
branches/simplest-thing/tests/gameobject.tests.rb
r208 r215 163 163 assert_match( /@test3/, rval, "@test3 ivar" ) 164 164 end 165 166 167 ### Cloned objects should get unique ids and mutexen 168 def test_clonedObjectsShouldHaveUniqueIds 169 printTestHeader "GameObject: cloned objects should have unique ids and mutexes" 170 171 derivClass = Class::new( FaerieMUD::GameObject ) 172 derivObj = derivClass::new 173 clonedObj = nil 174 175 assert_nothing_raised do 176 clonedObj = derivObj.clone 177 end 178 179 assert_not_same derivObj.id, clonedObj.id 180 assert_not_same derivObj.mutex, clonedObj.mutex 181 end 182 183 184 185 165 186 end 166 187
