The Trunk: CollectionsTests-tfel.240.mcz

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

The Trunk: CollectionsTests-tfel.240.mcz

commits-2
Tim Felgentreff uploaded a new version of CollectionsTests to project The Trunk:
http://source.squeak.org/trunk/CollectionsTests-tfel.240.mcz

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

Name: CollectionsTests-tfel.240
Author: tfel
Time: 1 May 2015, 11:04:36.037 am
UUID: 74204945-fbd6-6c49-9348-caafa98fb628
Ancestors: CollectionsTests-mt.239

Add a test case to check that ByteString>>findSubstring:in:startingAt:matchTable: behaves the same way as the primitive implementation (esp when using a negative index for startingAt:)

=============== Diff against CollectionsTests-mt.239 ===============

Item was added:
+ ----- Method: StringTest>>testFindSubstringInStartingAtMatchTable (in category 'tests - finding') -----
+ testFindSubstringInStartingAtMatchTable
+
+ | str tbl cm |
+ str := 'hello '.
+ tbl := String classPool at: #CaseSensitiveOrder.
+ self assert: (str findSubstring: ' ' in: str startingAt: 1 matchTable: tbl) = 6.
+ self assert: (str findSubstring: 'q' in: str startingAt: 1 matchTable: tbl) = 0.
+ self assert: (str findSubstring: 'q' in: str startingAt: -1 matchTable: tbl) = 0.
+ self assert: (str findSubstring: ' ' in: str startingAt: -1 matchTable: tbl) = 6.
+
+ "The next test ensures that the fallback code works just as well"
+ cm := (CompiledMethod newFrom: (ByteString >> #findSubstring:in:startingAt:matchTable:)).
+ cm objectAt: 1 put: (cm header bitAnd: 16r1FF bitInvert).
+ self assert: (cm valueWithReceiver: str arguments: {' '. str. 1. tbl}) = 6.
+ self assert: (cm valueWithReceiver: str arguments: {'q'. str. 1. tbl}) = 0.
+ self assert: (cm valueWithReceiver: str arguments: {'q'. str. -1. tbl}) = 0.
+ self assert: (cm valueWithReceiver: str arguments: {' '. str. -1. tbl}) = 6.
+ !