Skip to content

Immutable set size incorrect after filter #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
scabug opened this issue Feb 7, 2008 · 6 comments
Closed

Immutable set size incorrect after filter #454

scabug opened this issue Feb 7, 2008 · 6 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Feb 7, 2008

Calling filter on an immutable set with 5 elements causes it to report the wrong size initially. Iteration over the set seems to fix the problem. Here's a simple JUnit4 test case:

package test;

import org.junit.Test
import org.junit.Assert._

class SetTest {

@Test
def testSetSize = {
  val set = Set("0", "1", "2", "3", "4")
  assertEquals(5, set.size)
  
  val filteredSet = set filter (_ equals "0")
  assertEquals(5, set.size)
  assertEquals(1, filteredSet.size)
}

}

The error is the following:

testSetSize(test.SetTest) Time elapsed: 0.066 sec <<< FAILURE!
java.lang.AssertionError: expected:<5> but was:<9>
at org.junit.Assert.fail(Assert.java:74)
at org.junit.Assert.failNotEquals(Assert.java:448)
at org.junit.Assert.assertEquals(Assert.java:102)
at org.junit.Assert.assertEquals(Assert.java:117)
at test.SetTest.testSetSize(SetTest.scala:14)

Reproduced with Scala 2.6.1 and JDK 6 update 4.

This is a very hard to debug issue, so I think it should be given high priority. Thanks.

@scabug
Copy link
Author

scabug commented Feb 7, 2008

Imported From: https://issues.scala-lang.org/browse/SI-454?orig=1
Reporter: @ijuma
Attachments:

  • SetTest.scala (created on Feb 7, 2008 6:17:25 PM UTC, 329 bytes)

@scabug
Copy link
Author

scabug commented Feb 7, 2008

@ijuma said:
JUnit 4 test that shows the problem

@scabug
Copy link
Author

scabug commented Feb 7, 2008

@ijuma said:
I've attached a file with the test because the lines got a bit messed up in the in-line version.

@scabug
Copy link
Author

scabug commented Apr 19, 2008

@ijuma said:
This is the same issue as ticket #768. See comment #5 for more details.

@scabug
Copy link
Author

scabug commented Apr 21, 2008

@ijuma said:
Fixed in r14711 and r14727.

@scabug
Copy link
Author

scabug commented Jan 14, 2009

@odersky said:
Milestone 2.7.1 deleted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants