RegressionTests__ContextTest2.st
branchjv
changeset 1500 d406a10b2965
parent 1499 26a16a04219b
parent 1447 2351db93aa5b
equal deleted inserted replaced
1499:26a16a04219b 1500:d406a10b2965
    63     ^ ttt sender sender
    63     ^ ttt sender sender
    64 !
    64 !
    65 
    65 
    66 callRecursive: level withArg:argument thenDo:aBlock
    66 callRecursive: level withArg:argument thenDo:aBlock
    67     level == 0 ifTrue:[
    67     level == 0 ifTrue:[
    68         aBlock value:thisContext.
    68 	aBlock value:thisContext.
    69         ^ self.
    69 	^ self.
    70     ].
    70     ].
    71     self callRecursive:level-1 withArg:argument thenDo:aBlock
    71     self callRecursive:level-1 withArg:argument thenDo:aBlock
    72 
    72 
    73     "Created: / 07-03-2012 / 13:04:48 / cg"
    73     "Created: / 07-03-2012 / 13:04:48 / cg"
    74 !
    74 !
   131     ^ thisContext sender
   131     ^ thisContext sender
   132 !
   132 !
   133 
   133 
   134 raiseNotification
   134 raiseNotification
   135     NoHandlerError handle:[:ex |
   135     NoHandlerError handle:[:ex |
   136         ex return
   136 	ex return
   137     ] do:[
   137     ] do:[
   138         |t|
   138 	|t|
   139 
   139 
   140 %{
   140 %{
   141   extern void *__contextToDebug__;
   141   extern void *__contextToDebug__;
   142   __contextToDebug__ = (void *)__thisContext;
   142   __contextToDebug__ = (void *)__thisContext;
   143 %}.
   143 %}.
   144         t := MyNotification raiseRequestFrom:self.
   144 	t := MyNotification raiseRequestFrom:self.
   145 %{
   145 %{
   146   extern void *__contextToDebug__;
   146   extern void *__contextToDebug__;
   147   __contextToDebug__ = (void *)__thisContext;
   147   __contextToDebug__ = (void *)__thisContext;
   148 %}.
   148 %}.
   149         ^ t
   149 	^ t
   150     ].
   150     ].
   151     ^ nil.
   151     ^ nil.
   152 !
   152 !
   153 
   153 
   154 raiseWithContext
   154 raiseWithContext
   281     "
   281     "
   282 !
   282 !
   283 
   283 
   284 testContextRef8
   284 testContextRef8
   285     100000 timesRepeat:[
   285     100000 timesRepeat:[
   286         self raiseNotification.
   286 	self raiseNotification.
   287         self assert:(ObjectMemory spaceOf:exceptionObject suspendedContext) < 4.
   287 	self assert:(ObjectMemory spaceOf:exceptionObject suspendedContext) < 4.
   288     ].
   288     ].
   289 
   289 
   290     "
   290     "
   291      self new testContextRef8
   291      self new testContextRef8
   292     "
   292     "
   307 testDisplayString1
   307 testDisplayString1
   308     "the generated displayString must be a string (even if one of the args or receiver
   308     "the generated displayString must be a string (even if one of the args or receiver
   309      is a Twobytestring"
   309      is a Twobytestring"
   310 
   310 
   311     Transcript showCR:'1'.
   311     Transcript showCR:'1'.
   312     self 
   312     self
   313         callRecursive:3
   313 	callRecursive:3
   314         withArg:((Unicode16String new:2)
   314 	withArg:((Unicode16String new:2)
   315                                 at:1 put:(Character value:16r151);
   315 				at:1 put:(Character value:16r151);
   316                                 at:2 put:(Character value:16rFF00);
   316 				at:2 put:(Character value:16rFF00);
   317                                 yourself)
   317 				yourself)
   318         thenDo:[:context | 
   318 	thenDo:[:context |
   319                     self assert:(context displayString bitsPerCharacter == 8).
   319 		    self assert:(context displayString bitsPerCharacter == 8).
   320                     self assert:(context fullPrintString bitsPerCharacter == 8).
   320 		    self assert:(context fullPrintString bitsPerCharacter == 8).
   321                ].
   321 	       ].
   322 
   322 
   323     "
   323     "
   324      self new testDisplayString1
   324      self new testDisplayString1
   325     "
   325     "
   326 
   326 
   336     x := 1 @ 1.
   336     x := 1 @ 1.
   337 
   337 
   338     arg := x.
   338     arg := x.
   339 
   339 
   340     p := [
   340     p := [
   341         [
   341 	[
   342             lockSet critical:[set add:arg].
   342 	    lockSet critical:[set add:arg].
   343             arg perform:#x .
   343 	    arg perform:#x .
   344         ] ensure:[
   344 	] ensure:[
   345             lockSet critical:[set remove:arg].
   345 	    lockSet critical:[set remove:arg].
   346         ].
   346 	].
   347     ] fork.
   347     ] fork.
   348 
   348 
   349     "
   349     "
   350      self new testProcess1
   350      self new testProcess1
   351     "
   351     "
   358     set := Set new.
   358     set := Set new.
   359 
   359 
   360     x := 1 @ 1.
   360     x := 1 @ 1.
   361 
   361 
   362     p := [:arg |
   362     p := [:arg |
   363         [
   363 	[
   364             lockSet critical:[set add:arg].
   364 	    lockSet critical:[set add:arg].
   365             arg perform:#x.
   365 	    arg perform:#x.
   366         ] ensure:[
   366 	] ensure:[
   367             lockSet critical:[set remove:arg].
   367 	    lockSet critical:[set remove:arg].
   368         ].
   368 	].
   369     ] forkWith:(Array with:x).
   369     ] forkWith:(Array with:x).
   370 
   370 
   371     "
   371     "
   372      self new testProcess2
   372      self new testProcess2
   373     "
   373     "
   380     set := Set new.
   380     set := Set new.
   381 
   381 
   382     x := 1 @ 1.
   382     x := 1 @ 1.
   383 
   383 
   384     p := [:arg |
   384     p := [:arg |
   385         [
   385 	[
   386             lockSet critical:[set add:arg].
   386 	    lockSet critical:[set add:arg].
   387             arg perform:#x: with:1234.
   387 	    arg perform:#x: with:1234.
   388             lockSet critical:[set rehash].
   388 	    lockSet critical:[set rehash].
   389         ] ensure:[
   389 	] ensure:[
   390             lockSet critical:[set remove:arg].
   390 	    lockSet critical:[set remove:arg].
   391         ].
   391 	].
   392     ] forkWith:(Array with:x).
   392     ] forkWith:(Array with:x).
   393 
   393 
   394     "
   394     "
   395      self new testProcess3
   395      self new testProcess3
   396     "
   396     "
   453     |ex|
   453     |ex|
   454 
   454 
   455     ex := self newException.
   455     ex := self newException.
   456 someone exceptionObjectIs:ex.
   456 someone exceptionObjectIs:ex.
   457     ^ (ex
   457     ^ (ex
   458         suspendedContext:thisContext sender
   458 	suspendedContext:thisContext sender
   459         parameter:someone originator:someone)
   459 	parameter:someone originator:someone)
   460             raiseRequest.
   460 	    raiseRequest.
   461 ! !
   461 ! !
   462 
   462 
   463 !ContextTest2 class methodsFor:'documentation'!
   463 !ContextTest2 class methodsFor:'documentation'!
   464 
   464 
   465 version
   465 version