The Inbox: KernelTests-ct.376.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: KernelTests-ct.376.mcz

commits-2
Christoph Thiede uploaded a new version of KernelTests to project The Inbox:
http://source.squeak.org/inbox/KernelTests-ct.376.mcz

==================== Summary ====================

Name: KernelTests-ct.376
Author: ct
Time: 27 January 2020, 1:08:37.013199 pm
UUID: 7ed66f25-b6e3-1743-a84c-d8a571a6d1e7
Ancestors: KernelTests-ct.375

Tests #contextEnsure: and #contextOn:do:. Includes regression tests for Kernel-ct.1296.

=============== Diff against KernelTests-ct.375 ===============

Item was added:
+ ----- Method: ContextTest>>simulate: (in category 'private') -----
+ simulate: aBlock
+
+ | result |
+ [result := aBlock value] newProcess runUntil: [:ctxt | false].
+ ^ result!

Item was added:
+ ----- Method: ContextTest>>testContextEnsure (in category 'tests') -----
+ testContextEnsure
+
+ | sideEffect block result |
+ block := [
+ sideEffect := nil. "if the ensure block would be evaluated too early, this would raise an error"
+ thisContext insertSender: (
+ Context contextEnsure: [
+ sideEffect := sideEffect + 1]).
+ sideEffect := 0].
+
+ result := block value.
+ self assert: 0 equals: result.
+ self assert: 1 equals: sideEffect.!

Item was added:
+ ----- Method: ContextTest>>testContextEnsureSimulation (in category 'tests') -----
+ testContextEnsureSimulation
+ "Regression test for http://forum.world.st/BUG-s-in-Context-control-jump-runUntilErrorOrReturnFrom-td5107263.html"
+
+ | sideEffect block result |
+ block := [
+ sideEffect := nil. "if the ensure block would be evaluated too early, this would raise an error"
+ thisContext insertSender: (
+ Context contextEnsure: [
+ sideEffect := sideEffect + 1]).
+ sideEffect := 0].
+
+ self shouldnt: [result := self simulate: block] raise: Error. "this wrapper is important for avoiding a debugger chain when testing"
+ self assert: 0 equals: result.
+ self assert: 1 equals: sideEffect.!

Item was added:
+ ----- Method: ContextTest>>testContextEnsureSimulationWithError (in category 'tests') -----
+ testContextEnsureSimulationWithError
+ "Regression test for http://forum.world.st/BUG-s-in-Context-control-jump-runUntilErrorOrReturnFrom-td5107263.html"
+
+ | sideEffect block result |
+ block := [
+ sideEffect := nil. "if the ensure block would be evaluated too early, this would raise an error"
+ thisContext insertSender: (
+ Context contextEnsure: [
+ sideEffect := sideEffect + 1]).
+ sideEffect := 0.
+ self error].
+
+ self
+ shouldnt: [result := self simulate: [[block value] on: Error do: [42]]]
+ raise: Error. "this wrapper is important for avoiding a debugger chain when testing"
+ self assert: 42 equals: result.
+ self assert: 1 equals: sideEffect.!

Item was added:
+ ----- Method: ContextTest>>testContextEnsureWithError (in category 'tests') -----
+ testContextEnsureWithError
+
+ | sideEffect block result |
+ block := [
+ sideEffect := nil. "if the ensure block would be evaluated too early, this would raise an error"
+ thisContext insertSender: (
+ Context contextEnsure: [
+ sideEffect := sideEffect + 1]).
+ sideEffect := 0.
+ self error].
+
+ result := [block value] on: Error do: [42].
+ self assert: 42 equals: result.
+ self assert: 1 equals: sideEffect.!

Item was added:
+ ----- Method: ContextTest>>testContextOnDo (in category 'tests') -----
+ testContextOnDo
+
+ | sideEffect block result |
+ block := [
+ sideEffect := nil. "if the ensure block would be evaluated too early, this would raise an error"
+ thisContext insertSender: (
+ Context contextOn: Error do: [
+ sideEffect := sideEffect + 1]).
+ sideEffect := 0].
+
+ result := block value.
+ self assert: 0 equals: result.
+ self assert: 0 equals: sideEffect.!

Item was added:
+ ----- Method: ContextTest>>testContextOnDoSimulation (in category 'tests') -----
+ testContextOnDoSimulation
+ "Regression test for http://forum.world.st/BUG-s-in-Context-control-jump-runUntilErrorOrReturnFrom-td5107263.html"
+
+ | sideEffect block result |
+ block := [
+ sideEffect := nil. "if the ensure block would be evaluated too early, this would raise an error"
+ thisContext insertSender: (
+ Context contextOn: Error do: [
+ sideEffect := sideEffect + 1]).
+ sideEffect := 0].
+
+ self shouldnt: [result := self simulate: block] raise: Error. "this wrapper is important for avoiding a debugger chain when testing"
+ self assert: 0 equals: result.
+ self assert: 0 equals: sideEffect.!

Item was added:
+ ----- Method: ContextTest>>testContextOnDoSimulationWithError (in category 'tests') -----
+ testContextOnDoSimulationWithError
+ "Regression test for http://forum.world.st/BUG-s-in-Context-control-jump-runUntilErrorOrReturnFrom-td5107263.html"
+
+ | sideEffect block result |
+ block := [
+ sideEffect := nil. "if the ensure block would be evaluated too early, this would raise an error"
+ thisContext insertSender: (
+ Context contextOn: Error do: [
+ sideEffect := sideEffect + 1.
+ 42]).
+ sideEffect := 0.
+ self error].
+
+ self shouldnt: [result := self simulate: block] raise: Error. "this wrapper is important for avoiding a debugger chain when testing"
+ self assert: 42 equals: result.
+ self assert: 1 equals: sideEffect.!

Item was added:
+ ----- Method: ContextTest>>testContextOnDoWithError (in category 'tests') -----
+ testContextOnDoWithError
+
+ | sideEffect block result |
+ block := [
+ sideEffect := nil. "if the ensure block would be evaluated too early, this would raise an error"
+ thisContext insertSender: (
+ Context contextOn: Error do: [
+ sideEffect := sideEffect + 1.
+ 42]).
+ sideEffect := 0.
+ self error].
+
+ result := block value.
+ self assert: 42 equals: result.
+ self assert: 1 equals: sideEffect.!