Skip to content

Commit d461f18

Browse files
committed
Merge branch 'feature-cherry-pick-from-pr1211-to-3.0.x' into 3.1.x
2 parents 2f49a46 + 140e070 commit d461f18

15 files changed

+492
-93
lines changed

scalactic-test/src/test/scala/org/scalactic/anyvals/NegDoubleSpec.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ class NegDoubleSpec extends FunSpec with Matchers with PropertyChecks with TypeC
171171
NegDouble.ensuringValid(Double.NegativeInfinity).isNegInfinity shouldBe true
172172
NegDouble(-1.0).isNegInfinity shouldBe false
173173
}
174-
it("should not offer a isPosInfinity method") {
175-
"NegDouble(-1.0f).isPosInfinity" shouldNot compile
176-
}
177174
it("should be sortable") {
178175
val xs = List(NegDouble(-2.2), NegDouble(-4.4), NegDouble(-1.1),
179176
NegDouble(-3.3))

scalactic-test/src/test/scala/org/scalactic/anyvals/NegFiniteDoubleSpec.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ class NegFiniteDoubleSpec extends FunSpec with Matchers with PropertyChecks with
170170
it("should offer a isNegInfinity method that returns true if the instance is NegativeInfinity") {
171171
"NegFiniteDouble(-1.0).isNegInfinity" shouldNot compile
172172
}
173-
it("should not offer a isPosInfinity method") {
174-
"NegFiniteDouble(-1.0f).isPosInfinity" shouldNot compile
175-
}
176173
it("should be sortable") {
177174
val xs = List(NegFiniteDouble(-2.2), NegFiniteDouble(-4.4), NegFiniteDouble(-1.1),
178175
NegFiniteDouble(-3.3))

scalactic-test/src/test/scala/org/scalactic/anyvals/NegZFiniteFloatSpec.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ class NegZFiniteFloatSpec extends FunSpec with Matchers with PropertyChecks with
182182
it("should not offer a PositiveInfinity factory method") {
183183
"NegZFiniteFloat.PositiveInfinity" shouldNot compile
184184
}
185-
it("should not offer a isNegInfinity method") {
186-
"NegZFiniteFloat(-1.0f).isNegInfinity" shouldNot compile
187-
}
188185
it("should not offer a isPosInfinity method") {
189186
"NegZFiniteFloat(-1.0f).isPosInfinity" shouldNot compile
190187
}

scalactic-test/src/test/scala/org/scalactic/anyvals/NonZeroFiniteFloatSpec.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,6 @@ class NonZeroFiniteFloatSpec extends FunSpec with Matchers with PropertyChecks w
183183
it("should not offer a NegativeInfinity factory method") {
184184
"NonZeroFiniteFloat.NegativeInfinity" shouldNot compile
185185
}
186-
it("should not offer a isNegInfinity method") {
187-
"NonZeroFiniteFloat(-1.0f).isNegInfinity" shouldNot compile
188-
}
189-
it("should not offer a isPosInfinity method") {
190-
"NonZeroFiniteFloat(-1.0f).isPosInfinity" shouldNot compile
191-
}
192186
it("should offer a MinPositiveValue factory method") {
193187
NonZeroFiniteFloat.MinPositiveValue shouldEqual NonZeroFiniteFloat.ensuringValid(Float.MinPositiveValue)
194188
}

scalactic-test/src/test/scala/org/scalactic/anyvals/NonZeroLongSpec.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,11 @@ class NonZeroLongSpec extends FunSpec with Matchers with GeneratorDrivenProperty
225225
"takesNonZeroLong(0L)" shouldNot compile
226226
}
227227

228-
it("should not compile when -8 is passed in") {
229-
"takesNonZeroLong(-8)" shouldNot compile
230-
"takesNonZeroLong(-8L)" shouldNot compile
228+
it("should compile when -8 is passed in") {
229+
"takesNonZeroLong(-8)" should compile
230+
takesNonZeroLong(-8) shouldEqual -8L
231+
"takesNonZeroLong(-8L)" should compile
232+
takesNonZeroLong(-8L) shouldEqual -8L
231233
}
232234

233235
it("should not compile when x is passed in") {

scalactic-test/src/test/scala/org/scalactic/anyvals/PosDoubleSpec.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,6 @@ class PosDoubleSpec extends FunSpec with Matchers with PropertyChecks with TypeC
173173
PosDouble.ensuringValid(Double.PositiveInfinity).isPosInfinity shouldBe true
174174
PosDouble(1.0).isPosInfinity shouldBe false
175175
}
176-
it("should not offer a isNegInfinity method") {
177-
"PosDouble(1.0).isNegInfinity" shouldNot compile
178-
}
179176

180177
it("should be sortable") {
181178
val xs = List(PosDouble(2.2), PosDouble(4.4), PosDouble(1.1),

scalactic-test/src/test/scala/org/scalactic/anyvals/PosFiniteDoubleSpec.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ class PosFiniteDoubleSpec extends FunSpec with Matchers with PropertyChecks with
172172
it("should not ffer a isPosInfinity method") {
173173
"PosFiniteDouble(1.0).isPosInfinity" shouldNot compile
174174
}
175-
it("should not offer a isNegInfinity method") {
176-
"PosFiniteDouble(1.0).isNegInfinity" shouldNot compile
177-
}
178175

179176
it("should be sortable") {
180177
val xs = List(PosFiniteDouble(2.2), PosFiniteDouble(4.4), PosFiniteDouble(1.1),

scalactic-test/src/test/scala/org/scalactic/anyvals/PosZFiniteFloatSpec.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ class PosZFiniteFloatSpec extends FunSpec with Matchers with PropertyChecks with
182182
it("should not offer a NegativeInfinity factory method") {
183183
"PosZFiniteFloat.NegativeInfinity" shouldNot compile
184184
}
185-
it("should not offer a isPosInfinity method") {
186-
"PosZFiniteFloat(1.0f).isPosInfinity" shouldNot compile
187-
}
188185
it("should not offer a isNegInfinity method") {
189186
"PosZFiniteFloat(1.0f).isNegInfinity" shouldNot compile
190187
}

scalatest-test/src/test/scala/org/scalatest/AssertionsSpec.scala

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,7 @@ class AssertionsSpec extends FunSpec {
17971797
|assert(org.exists(_ == 'b'))
17981798
""".stripMargin)
17991799
}
1800+
18001801
it("should result in type Assertion and, on success, return the Succeeded value") {
18011802
val x = 1
18021803
assert(assert(x + 1 == 2) eq Succeeded)
@@ -6152,6 +6153,26 @@ class AssertionsSpec extends FunSpec {
61526153
assert(e.failedCodeFileName === (Some(fileName)))
61536154
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 6)))
61546155
}
6156+
6157+
it("should do nothing when used with 'val i: Int = null'") {
6158+
assertTypeError("val i: Int = null")
6159+
}
6160+
6161+
it("should throw TestFailedException with correct message and stack depth when the code compiles with implicit view in scope") {
6162+
import scala.collection.JavaConverters._
6163+
6164+
val arrayList: java.util.ArrayList[String] = new java.util.ArrayList[String]()
6165+
6166+
arrayList.add("Foo")
6167+
arrayList.add("Bar")
6168+
6169+
val e = intercept[TestFailedException] {
6170+
assertTypeError("arrayList.asScala")
6171+
}
6172+
assert(e.message == Some(Resources.expectedTypeErrorButGotNone("arrayList.asScala")))
6173+
assert(e.failedCodeFileName === (Some(fileName)))
6174+
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 4)))
6175+
}
61556176
}
61566177

61576178
describe("when used with triple quotes string literal with stripMargin") {
@@ -6191,7 +6212,36 @@ class AssertionsSpec extends FunSpec {
61916212
assert(e.failedCodeFileName === (Some(fileName)))
61926213
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 10)))
61936214
}
6215+
6216+
it("should do nothing when used with 'val i: Int = null'") {
6217+
assertTypeError(
6218+
"""
6219+
|val i: Int = null
6220+
|""".stripMargin
6221+
)
6222+
}
6223+
6224+
it("should throw TestFailedException with correct message and stack depth when the code compiles with implicit view in scope") {
6225+
import scala.collection.JavaConverters._
6226+
6227+
val arrayList: java.util.ArrayList[String] = new java.util.ArrayList[String]()
6228+
6229+
arrayList.add("Foo")
6230+
arrayList.add("Bar")
6231+
6232+
val e = intercept[TestFailedException] {
6233+
assertTypeError(
6234+
"""
6235+
|arrayList.asScala
6236+
|""".stripMargin
6237+
)
6238+
}
6239+
assert(e.message == Some(Resources.expectedTypeErrorButGotNone(Prettifier.lineSeparator + "arrayList.asScala" + Prettifier.lineSeparator)))
6240+
assert(e.failedCodeFileName === (Some(fileName)))
6241+
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 8)))
6242+
}
61946243
}
6244+
61956245
it("should result in type Assertion and, on success, return the Succeeded value") {
61966246
assert(assertTypeError("val x: String = 1") eq Succeeded)
61976247
}
@@ -6226,6 +6276,22 @@ class AssertionsSpec extends FunSpec {
62266276
assertDoesNotCompile("val i: Int = null")
62276277
}
62286278

6279+
it("should throw TestFailedException with correct message and stack depth when the code compiles with implicit view in scope") {
6280+
import scala.collection.JavaConverters._
6281+
6282+
val arrayList: java.util.ArrayList[String] = new java.util.ArrayList[String]()
6283+
6284+
arrayList.add("Foo")
6285+
arrayList.add("Bar")
6286+
6287+
val e = intercept[TestFailedException] {
6288+
assertDoesNotCompile("arrayList.asScala".stripMargin)
6289+
}
6290+
assert(e.message == Some(Resources.expectedCompileErrorButGotNone("arrayList.asScala")))
6291+
assert(e.failedCodeFileName === (Some(fileName)))
6292+
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 4)))
6293+
}
6294+
62296295
}
62306296

62316297
describe("when used with triple quotes string literal with stripMargin") {
@@ -6273,6 +6339,25 @@ class AssertionsSpec extends FunSpec {
62736339
|""".stripMargin
62746340
)
62756341
}
6342+
6343+
it("should throw TestFailedException with correct message and stack depth when the code compiles with implicit view in scope") {
6344+
import scala.collection.JavaConverters._
6345+
6346+
val arrayList: java.util.ArrayList[String] = new java.util.ArrayList[String]()
6347+
6348+
arrayList.add("Foo")
6349+
arrayList.add("Bar")
6350+
6351+
val e = intercept[TestFailedException] {
6352+
assertDoesNotCompile(
6353+
"""
6354+
|arrayList.asScala
6355+
|""".stripMargin)
6356+
}
6357+
assert(e.message == Some(Resources.expectedCompileErrorButGotNone(Prettifier.lineSeparator + "arrayList.asScala" + Prettifier.lineSeparator)))
6358+
assert(e.failedCodeFileName === (Some(fileName)))
6359+
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 7)))
6360+
}
62766361
}
62776362
}
62786363

@@ -6305,6 +6390,17 @@ class AssertionsSpec extends FunSpec {
63056390
assert(e.failedCodeFileName === (Some(fileName)))
63066391
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 6)))
63076392
}
6393+
6394+
it("should do nothing when the code compiles with implicit view in scope") {
6395+
import scala.collection.JavaConverters._
6396+
6397+
val arrayList: java.util.ArrayList[String] = new java.util.ArrayList[String]()
6398+
6399+
arrayList.add("Foo")
6400+
arrayList.add("Bar")
6401+
6402+
assertCompiles("arrayList.asScala")
6403+
}
63086404
}
63096405

63106406
describe("when used with triple quotes string literal with stripMargin") {
@@ -6346,6 +6442,20 @@ class AssertionsSpec extends FunSpec {
63466442
assert(e.failedCodeFileName === (Some(fileName)))
63476443
assert(e.failedCodeLineNumber === (Some(thisLineNumber - 10)))
63486444
}
6445+
6446+
it("should do nothing when the code compiles with implicit view in scope") {
6447+
import scala.collection.JavaConverters._
6448+
6449+
val arrayList: java.util.ArrayList[String] = new java.util.ArrayList[String]()
6450+
6451+
arrayList.add("Foo")
6452+
arrayList.add("Bar")
6453+
6454+
assertCompiles(
6455+
"""
6456+
|arrayList.asScala
6457+
|""".stripMargin)
6458+
}
63496459
}
63506460
it("should result in type Assertion and, on success, return the Succeeded value") {
63516461
assert(assertCompiles("val x: Int = 1") eq Succeeded)

0 commit comments

Comments
 (0)