Commit Graph
46 Commits
Author SHA1 Message Date
Robert Jordan c42abafd5b In System.Collections.Generic:
2010-01-24  Robert Jordan  <[email protected]>

	* Dictionary.cs: Fix deserialization compatibility with MS.NET.
	Fixes bug #474009.

In Test/System.Collections.Generic:
2010-01-24  Robert Jordan  <[email protected]>

	* DictionaryTest.cs: Add test case for bug #474009.


svn path=/trunk/mcs/; revision=150089
2010-01-24 01:04:18 +00:00
Raja R Harinath 162d3490c5 Dictionary: Ensure that invalid arrays to CopyTo result in ArgumentExceptions.
* System.Collections.Generic/Dictionary.cs (CopyToCheck, Do_CopyTo):
Carve out of ...
(CopyTo): ... this.
(Do_ICollectionCopyTo): Carve out of ICollection.CopyTo.  Convert
type-cast exceptions to ArgumentExceptions.
(KeyCollection.CopyTo): Use them.
(ValueCollection.CopyTo): Use them.
* Test/System.Collections.Generic/DictionaryTest.cs (ICollectionCopyTo):
Test various odd scenarios where .NET CopyTo does _not_ throw an exception.
(ICollectionCopyTo_ex1..4): Ensure that ArgumentExceptions are
thrown in appropriate cases.

svn path=/trunk/mcs/; revision=142427
2009-09-22 17:39:52 +00:00
Raja R Harinath f741a048f0 IList implementation: convert NullReferenceException to ArgumentException
* List.cs (IList.this.set): Convert NullReference and InvalidCast
exceptions into ArgumentExceptions.
(IList.Add, IList.Contains, IList.IndexOf, IList.Insert, IList.Remove):
Convert NullReferenceException to ArgumentException.
* ListTest.cs: Add a few testcases for IList interface, using null
values with a List<int>.

svn path=/trunk/mcs/; revision=139159
2009-07-31 10:25:04 +00:00
Raja R Harinath 1e3534eca1 Test the Dictionary Keys and Values slices
* DictionaryTest.cs (KeyEnumerator_Current): New test.  Test the
Keys slice enumerator.
(ValueEnumerator_Current): Likewise, for the Values slice.

svn path=/trunk/mcs/; revision=139117
2009-07-30 19:47:53 +00:00
Raja R Harinath ef326448f4 List<>-relevant fix for #491858 and #517415
* System.Collections.Generic/List.cs (Enumerator.current): New.
(Enumerator.MoveNext): Update it.
(Enumerator.Current): Don't verify any invariants.
(Enumerator.Dispose): Set 'l' to null.
* Test/System.Collections.Generic/ListTest.cs (Enumerator_Current):
New test, includes relevant parts of #491858 and #517415.

svn path=/trunk/mcs/; revision=139087
2009-07-30 14:55:24 +00:00
Raja R Harinath a22621964d Fix Dictionary<,>-relevant parts of #491858 and #517415
* System.Collections.Generic/Dictionary.cs (Enumerator.current): New.
(Enumerator.MoveNext): Update it.
(Enumerator.Current): Don't verify any invariants.
* Test/System.Collections.Generic/DictionaryTest.cs (Enumerator_Current):
New test, includes relevant parts of #491858 and #517415.

svn path=/trunk/mcs/; revision=139082
2009-07-30 13:52:39 +00:00
Jb Evain 65f396a229 2009-04-02 Jb Evain <[email protected]>
* DictionaryTest.cs: add test for bug #328036.


svn path=/trunk/mcs/; revision=130885
2009-04-02 17:33:53 +00:00
Jb Evain 89b0dc7b11 2008-11-14 Jb Evain <[email protected]>
* DictionaryTest.cs: add tests for #444778.


svn path=/trunk/mcs/; revision=118842
2008-11-14 11:47:36 +00:00
Jb Evain 0338541bbc 2008-11-14 Jb Evain <[email protected]>
* DictionaryTest.cs: add tests for bug #444768.


svn path=/trunk/mcs/; revision=118839
2008-11-14 10:36:55 +00:00
Zoltan Varga 2785965055 2008-10-06 Zoltan Varga <[email protected]>
* DictionaryTest.cs: Add a test for #432441.

svn path=/trunk/mcs/; revision=114916
2008-10-06 03:38:50 +00:00
Jb Evain 3ab1fbeb90 2008-09-29 Jb Evain <[email protected]>
* DictionaryTest.cs: test for null argument for ContainsKey.
	Patch by Jonathan Anderson  <[email protected]>


svn path=/trunk/mcs/; revision=114372
2008-09-29 07:44:17 +00:00
Jb Evain abb97797a2 2008-09-24 Jb Evain <[email protected]>
* DictionaryTest.cs: add tests for bug #429530.


svn path=/trunk/mcs/; revision=113953
2008-09-24 13:33:27 +00:00
Jb Evain fd6f6c88a8 2008-09-12 Jb Evain <[email protected]>
* DictionaryTest.cs: add tests for #425693.


svn path=/trunk/mcs/; revision=112908
2008-09-12 21:01:51 +00:00
Andreas N 26c0c9d1dd 2008-06-16 Andreas Nahr <[email protected]>
* DictionaryTest.cs: Add test for an incompatibility

svn path=/trunk/mcs/; revision=105871
2008-06-15 23:01:30 +00:00
Gert Driesen 17e1a45680 * DictionaryTest.cs: Added not working tests for bug #384723. Spaces
to tabs.

svn path=/trunk/mcs/; revision=102188
2008-04-30 09:49:39 +00:00
Sebastien Pouliot 320c4febec 2008-03-21 Sebastien Pouliot <[email protected]>
* EqualityComparerTest.cs: New. Add test cases for using null with 
	GetHashCode (bug #372892).


svn path=/trunk/mcs/; revision=98738
2008-03-21 14:41:52 +00:00
Zoltan Varga d3000844fc 2008-01-06 Zoltan Varga <[email protected]>
* ListTest.cs: Make some tests public.

svn path=/trunk/mcs/; revision=92369
2008-01-06 22:04:05 +00:00
Sebastien Pouliot 5b59c8d0c5 2007-11-05 Sebastien Pouliot <[email protected]>
* DictionaryTest.cs: Test case for #322783 based on Francisco Moraes
	sample code.


svn path=/trunk/mcs/; revision=88941
2007-11-05 23:53:05 +00:00
Jonathan Chambers 1888bc79f1 2006-04-16 Jonathan Chambers <[email protected]>
* List.cs: Clear entry in RemoveAt after removing item. 
	Fixes bug #81387.

svn path=/trunk/mcs/; revision=75788
2007-04-16 20:54:22 +00:00
Gert Driesen dfdbcf7fdd * Comparer.cs: Renamed IComparableOfTComparer<T> to GenericComparer<T>
to fix binary serialization compatibility with MS.
* ComparerTest.cs: Added test for bug #80929. Added tests to verify
binary serialization compatibility.
* IListTest.cs: Fixed header.
* corlib_test.dll.sources: Added ComparerTest.cs.

svn path=/trunk/mcs/; revision=73964
2007-03-08 20:22:06 +00:00
Gert Driesen d2b7b476e7 * corlib_test.dll.sources: Added IListTest.cs.
* IListTest.cs: Added test for bug #80260.

svn path=/trunk/mcs/; revision=73900
2007-03-07 19:08:24 +00:00
Gert Driesen a22cecf689 * List.cs: Fixed binary serialization compatibility with MS.NET.
Increment version whenever _items is modified; this fixes version
checks in Enumerator.
* ListTest.cs: Added tests for binary serialization, and Enumerator
version checks.

svn path=/trunk/mcs/; revision=66698
2006-10-15 14:17:58 +00:00
Atsushi Eno 089398a170 2006-05-08 Atsushi Enomoto <[email protected]>
* ArrayTest.cs : use proper comparer in IndexOf() and LastIndexOf().
	  Patch by Kazuki Oikawa. Fixed bug #77277.

	* List.cs : use proper comparer in Contains(), IndexOf() and
	  LastIndexOf(). Patch by Kazuki Oikawa. Fixed bug #77277.

	* ArrayTest.cs : test for bug #77277 by Kazuki Oikawa.

	* ListTest.cs : test for bug #77277 by Kazuki Oikawa.


svn path=/trunk/mcs/; revision=60396
2006-05-08 07:34:06 +00:00
Ankit Jain bff6e6ed35 In class/corlib/System.Collections.Generic:
* List.cs (CheckIndex): Check for -ve indices and allow index == size.
	(Insert): Use CheckIndex.

In class/corlib/Test/System.Collections.Generic:

	* ListTest.cs: Add some tests for InsertRange.


svn path=/trunk/mcs/; revision=58069
2006-03-16 17:04:44 +00:00
Raja R Harinath ae6559b8ab In System.Collections.Generic:
Speed up remove.  Use 'dict[k]=v' as a self-tuning hint.
	* Dictionary.cs (GetSlot): Move data-structure traversal to ...
	(GetPrev): ... this.  Returns the slot prior to the place we're
	looking for, or null if that place is the head of the chain.
	(Remove): Use it.
	(this.set): Use it.  Implement move-to-front on set.

	* Dictionary.cs (ToTKey, ToTValue): New helpers to convert from
	type 'object'.
	(IDictionary.this, IDictionary.Add): Use them.
	(IDictionary.Contains, IDictionary.Remove): If the types don't
	match, do nothing.

In Test/System.Collections.Generic:
	* DictionaryTest.cs (IDictionary_*): Add a few tests for the
	IDictionary explicit implementation.

svn path=/trunk/mcs/; revision=55946
2006-01-23 15:21:09 +00:00
Raja R Harinath 18b3383ec5 In System.Collections.Generic:
Fix to pass new nunit tests.
	* Dictionary.cs (ShimEnumerator): New class.  Implement the
	requirement that ((IDictionary) foo).GetEnumerator ().Current has
	type DictionaryEntry.
	(IDictionary.GetEnumerator): Use ShimEnumerator.
	(Enumerator.Current): Now has type KeyValuePair<TKey, TValue>.
	(Enumerator.MoveNext): Use VerifyState.
	(Enumerator.VerifyState): Move validation of 'current' field to ...
	(Enumerator.CurrentSlot): ... this.
	(Enumerator.Current, Enumerator.IDictionaryEnumerator.Entry):
	Use CurrentSlot.
	(CopyTo, ICollection.CopyTo): Use subtle reasoning to replace a
	'>=' with a '>'.  Don't throw an ArgumentException when
	index==array.Length && Count==0.
	(KeyCollection.CopyTo, ValueCollection.CopyTo): Likewise, and thus
	obviate the need to check (dictionary.Count == 0).

In Test/System.Collections.Generic:
	* DictionaryTest.cs: Remove NotWorking annotations.
	(Empty_CopyTo, Empty_Values_CopyTo): Fix tests to check that
	CopyTo from an empty dictionary does not throw an exception when
	'index==array.Length'.
	(PlainEnumeratorReturnTest): Check the type of 'Entry' property too.

svn path=/trunk/mcs/; revision=55781
2006-01-19 13:32:39 +00:00
Atsushi Eno 80596125e4 2006-01-19 Atsushi Enomoto <[email protected]>
* DictionaryTest.cs : fixed several tests to not fail under .NET 2.0
	  and thus marked some as NotWorking. Numbered some assertions.


svn path=/trunk/mcs/; revision=55774
2006-01-19 09:47:00 +00:00
Sebastien Pouliot fb568bc44a 2005-12-21 Sebastien Pouliot <[email protected]>
* ListTest.cs: Added test cases for #77039 for sorting a list with
	IComparable (generic or not) and without IComparable (exception).


svn path=/trunk/mcs/; revision=54697
2005-12-21 18:23:31 +00:00
Sebastien Pouliot d756811236 2005-12-20 Sebastien Pouliot <[email protected]>
* ListTest.cs: Added test case for #76361 for sorting the list with a
	generic comparer.


svn path=/trunk/mcs/; revision=54655
2005-12-20 13:58:34 +00:00
Sebastien Pouliot 67eebba85b * DictionaryTest.cs: Added test cases for CopyTo, including a test for
DictionaryEntry.
	* ListTest.cs: Added test case for #77019 when copying from an empty 
	dictionary.

2005-12-19  Sebastien Pouliot  <[email protected]>


svn path=/trunk/mcs/; revision=54615
2005-12-19 17:16:52 +00:00
Sebastien Pouliot 40d9944bcc 2005-12-19 Sebastien Pouliot <[email protected]>
* ListTest.cs: Added test case for a binary search with an empty list
	(bug #77030). Removed IsReadOnly test case as this isn't part of the 
	public API anymore.


svn path=/trunk/mcs/; revision=54609
2005-12-19 15:59:45 +00:00
Martin Baulig 12f6496288 2005-08-16 Martin Baulig <[email protected]>
* DictionaryTest.cs (IEnumeratorGenericTest): Reflect latest
	`KeyValuePair<K,V>' API changes.


svn path=/trunk/mcs/; revision=48429
2005-08-16 14:06:23 +00:00
Raja R Harinath cf760a97e8 In System.Collections.Generic:
Introduce some thread-safety by removing the modify-on-read
	move-to-front heuristic.
	* Dictionary.cs (_enumeratorGeneration, _enumerators): Remove.
	(Count): Add internal property set.  Invalidate enumerators when
	Count is changed.  Change all references of _usedSlots to Count.
	(this): Invalidate enumerators when the value of some slot is
	changed, even if the layout of the data-structure isn't modified.
	(DoHash): Remove null-key check.  All codepaths leading to this
	function already have the check.
	(GetSlot): Remove move-to-front heuristic.
	(Remove): Update.

In Test/System.Collections.Generic:
	* DictionaryTest.cs (FailFastTest1, FailFastTest2, FailFastTest3):
	New tests to ensure that enumerators are invalidated on
	modifications to the dictionary.

svn path=/trunk/mcs/; revision=46538
2005-06-27 08:36:29 +00:00
Raja R Harinath 497020b7ff In System.Collections.Generic:
* Dictionary.cs (_generation, _enumeratorGeneration, _enumerators):
	New fields to implement fail-fast semantics.  All code that
	modifies the table increment _generation.
	(GetSlot): Use _hcp to compare keys.  Return the slot containing
	the key, rather than the index.  Avoid move-to-front heuristic
	when there's an enumerator coursing through the table.
	(this, Add, TryGetValue, ContainsKey, Remove): Update to change.
	(Enumerator.Enumerator): Save the generation of the dictionary.
	(Enumerator.Dispose): Inform dictionary that the enumerator is no more.
	(Enumerator.MoveNext, Enumerator.VerifyState): Fail if the
	dictionary has been modified.

In Test/System.Collections.Generic:
	* DictionaryTest.cs (KeyValueEnumeratorTest): Add test for infloop
	if dictionary is read while it's being enumerated.

svn path=/trunk/mcs/; revision=46370
2005-06-22 14:42:13 +00:00
David Waite b2e0ae57fb 2005-06-20 David waite <[email protected]>
* List.cs : substantial changes and optimizations
    (AddCollection, AddEnumerable): new internal specializations of AddRange
    (AsReadOnly): returns specific IList<T> to match ms.net 2.0b2 api.
    (Clear): reset size to zero on clear
    (ConvertAll): catch null converter, use Add to prevent OutOfBounds
    exception
    (FindAll, FindIndex, FindLast, FindLastIndex, RemoveAll, TrueForAll): 
    check for null match
    (FindLastIndex): correct index parameters based on ms.net 2005b2 behavior
    (ForEach): catch null action
    (CheckIndex): new internal function similar to CheckRange for functions
    which only provide a starting index
    (InsertCollection, InsertEnumerable): new internal specializations of
    InsertRange
    (ReadOnlyList): removed, ReadOnlyCollection in 
    System.Collections.ObjectModel is used instead now 
    * ListTest.cs: Substantial new tests

svn path=/trunk/mcs/; revision=46283
2005-06-21 07:17:50 +00:00
David Waite 7bb5e539d1 2005-06-16 David Waite <[email protected]>
* Dictionary.cs (EnumerationMode): Remove.
    (Enumerator): Remove return type flag - legacy return is expected to
    always return a DictionaryEntry
    (Enumerator): Make constructor internal, it is not public on ms.net 
    beta 2
    (Enumerator.MoveNext): Fix endless loop on enumerator use
    (VerifyState): Added method to check state preconditions and throw
    appropriate exceptions.
    (KeyCollection,ValueCollection): Mark sealed to match ms.net beta 2
    (KeyCollection.Enumerator._hostEnumerator): make exact struct type,
    rather than boxing and using by interface
    (KeyCollection.Enumerator.Dispose): use default to clear Enumerator
    (ValueCollection.Enumerator._hostEnumerator): make exact struct type,
    rather than boxing and using by interface
    (ValueCollection.Enumerator.Dispose): use default to clear Enumerator
    * EqualityComparer.cs (DefaultComparer, IEquatableOfTEqualityComparer):
    Mark as serializable.
    * DictionaryTest.cs (AddTest3): Added test of simple interaction with
    struct dictionary
    (AddDuplicateTest,IndexerGetNullTest,IndexerSetNullTest): Added tests
    for exceptional cases to verify correct exceptions
    (TryGetValueTest): check return value from TryGetValue
    (KeyValueEnumeratorTest): Added test from verification of ms.net beta2
    behavior for non-generic IEnumerator/IDictionaryEnumerator behavior
    against Dictionary<>
    (SerializationTest): Added test to utilize serialization routines.

svn path=/trunk/mcs/; revision=46200
2005-06-19 02:36:21 +00:00
Raja R Harinath 3bb11dfff8 In System.Collections.Generic:
* Dictionary.cs (GetKeys, GetValues): Remove.
	(SetThreshold): New function to calculate the resize threshold.
	(CopyTo): Don't use foreach syntax.
	(ContainsValue): Likewise.  Use default equality comparer of the
	value type.
	(GetObjectData): Use CopyTo to copy into temporary array.  Don't
	save redundant _usedSlots and _threshold.
	(OnDeserialization): Rewrite.
	(ICollection<>.CopyTo): Forward to CopyTo.
	(Enumerator._nextIndex): Rename to from _index.
	(Enumerator._next, Enumerator.FixNext): Remove.
	(Enumerator.Current): Rewrite to avoid need for _next.
	(Enumerator.IEnumerator.Reset): Update.
	(KeyCollection): Is also IEnumerable<TKey> and IEnumerable.
	Update methods to conform to standard.
	(KeyCollection.GetEnumerator): Restore.  Return the correct type.
	(KeyCollection.Enumerator): Rename from KeyEnumerator.  Simple
	wrapper that forwards to Dictionary<,>.Enumerator.
	(ValueCollection): Likewise.

In Test/System.Collections.Generic:
	* DictionaryTest.cs (SliceCollectionsEnumeratorTest): New test
	based on #75053.

svn path=/trunk/mcs/; revision=46087
2005-06-16 12:45:33 +00:00
Ankit Jain 278885d5ba 2005-06-07 Ankit Jain <[email protected]>
* DictionaryTest.cs (KeyValueEnumeratorTest): Added new test.
	

svn path=/trunk/mcs/; revision=45604
2005-06-07 22:31:45 +00:00
Raja R Harinath d965e55ee7 * ListTest.cs (TestGetRange): Add missing ';'. Actually compare
the length of the list.

svn path=/trunk/mcs/; revision=44743
2005-05-19 09:40:10 +00:00
Miguel de Icaza fa23caf4d4 Added List tests
svn path=/trunk/mcs/; revision=44697
2005-05-18 17:35:38 +00:00
Atsushi Eno f12881b652 2005-05-13 Atsushi Enomoto <[email protected]>
* corlib_test.dll.sources,
	  corlib.dll.sources: generic Queue.cs and Stack.cs are now in System.
	* System_test.dll.sources,
	  System.dll.sources: generic Queue.cs and Stack.cs are now in System.

	* Queue.cs, Stack.cs: moved to System.dll

	* QueueTest.cs, StackTest.cs: They are now in System.dll


svn path=/trunk/mcs/; revision=44484
2005-05-13 03:50:32 +00:00
Raja R Harinath 59580fe54f * DictionaryTest.cs (MyTest.GetHashCode): Add to silence a compiler warning.
svn path=/trunk/mcs/; revision=44065
2005-05-05 08:53:34 +00:00
Raja R Harinath 87da49f1b0 In System.Collections.Generic:
* Dictionary.cs: Update to draft of Feb 27.  Add some argument checks.
	(GetSlot): Don't throw KeyNotFoundException.  Unify all list
	traversals in here.  Move found key to head of chain, and return
	the index of the chain suitable for/containing the key.
	(Item, Add, Remove): Simplify, and remove FIXMEs.
	(Resize): Reuse linked list nodes from old table.

In Test/System.Collections.Generic:
	* DictionaryTest.cs: Update.

svn path=/trunk/mcs/; revision=42508
2005-04-04 10:48:49 +00:00
Ben Maurer 834984e9d8 In .:
2005-04-02  Ben Maurer  <[email protected]>

	* corlib_test.dll.sources: Add new test.

In Test/System.Collections.Generic:
2005-04-02  Ben Maurer  <[email protected]>

	* DictionaryTest.cs: new test.


svn path=/trunk/mcs/; revision=42491
2005-04-02 19:44:08 +00:00
Ben Maurer e5d77c7e45 In System.Collections.Generic:
2005-01-29  Ben Maurer  <[email protected]>

	* Queue.cs: `duh' bugs.

In Test/System.Collections.Generic:
2005-01-29  Ben Maurer  <[email protected]>

	* QueueTest.cs: new Test.


svn path=/trunk/mcs/; revision=39753
2005-01-29 18:56:34 +00:00
Ben Maurer 6445c1c9c6 In .:
2004-12-27  Ben Maurer  <[email protected]>

	* corlib_test.dll.sources: Add s.col.gen.stack test

In Test/System.Collections.Generic:
2004-12-27  Ben Maurer  <[email protected]>

	* StackTest.cs: new Test.


svn path=/trunk/mcs/; revision=38124
2004-12-28 03:08:17 +00:00