summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-03-22 18:22:49 +0000
committerMartin Odersky <odersky@gmail.com>2007-03-22 18:22:49 +0000
commit800ce668acb253c3d5e57b5230d913ad155a0f74 (patch)
treea7526664522ee11348087e5bb80957182b9ba17e /test/files/neg
parent0196b0e057dcd62903b6635f53d2857ea182280a (diff)
downloadscala-800ce668acb253c3d5e57b5230d913ad155a0f74.tar.gz
scala-800ce668acb253c3d5e57b5230d913ad155a0f74.tar.bz2
scala-800ce668acb253c3d5e57b5230d913ad155a0f74.zip
modified sinsibility checks and test cases
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/bug193.check17
-rw-r--r--test/files/neg/bug193.scala74
-rw-r--r--test/files/neg/checksensible.check10
-rw-r--r--test/files/neg/checksensible.scala7
4 files changed, 106 insertions, 2 deletions
diff --git a/test/files/neg/bug193.check b/test/files/neg/bug193.check
new file mode 100644
index 0000000000..2b2e4485a5
--- /dev/null
+++ b/test/files/neg/bug193.check
@@ -0,0 +1,17 @@
+actual = class Objectfalse
+bug193.scala:39: warning: comparing values of types scala.Int and java.lang.Object using `==' will always yield false
+ (0 ) == y;
+ ^
+actual = class Objectfalse
+bug193.scala:41: warning: comparing values of types scala.Int and java.lang.Object using `!=' will always yield true
+ (0 ) != y;
+ ^
+actual = class Objectfalse
+bug193.scala:54: warning: comparing values of types scala.Int and java.lang.Object using `==' will always yield false
+ (x ) == y;
+ ^
+actual = class Objectfalse
+bug193.scala:56: warning: comparing values of types scala.Int and java.lang.Object using `!=' will always yield true
+ (x ) != y;
+ ^
+four warnings found
diff --git a/test/files/neg/bug193.scala b/test/files/neg/bug193.scala
new file mode 100644
index 0000000000..f4ed3f4643
--- /dev/null
+++ b/test/files/neg/bug193.scala
@@ -0,0 +1,74 @@
+// $Id: bug193.scala 9110 2006-11-01 16:03:28 +0000 (Wed, 01 Nov 2006) mihaylov $
+
+trait Test {
+
+ def fun_00(x: Int): Unit = {
+ (0: Any) == 0;
+ (0 ) == 0;
+ (0: Any) != 0;
+ (0 ) != 0;
+ ()
+ }
+
+ def fun_i0(x: Int): Unit = {
+ (x: Any) == 0;
+ (x ) == 0;
+ (x: Any) != 0;
+ (x ) != 0;
+ ()
+ }
+
+ def fun_o0(x: AnyRef): Unit = {
+ (x: Any) == 0;
+ (x ) == 0;
+ (x: Any) != 0;
+ (x ) != 0;
+ ()
+ }
+
+ def fun_0i(y: Int): Unit = {
+ (0: Any) == y;
+ (0 ) == y;
+ (0: Any) != y;
+ (0 ) != y;
+ ()
+ }
+
+ def fun_0o(y: AnyRef): Unit = {
+ (0: Any) == y;
+ (0 ) == y;
+ (0: Any) != y;
+ (0 ) != y;
+ ()
+ }
+
+ def fun_ii(x: Int, y: Int): Unit = {
+ (x: Any) == y;
+ (x ) == y;
+ (x: Any) != y;
+ (x ) != y;
+ ()
+ }
+ def fun_io(x: Int, y: AnyRef): Unit = {
+ (x: Any) == y;
+ (x ) == y;
+ (x: Any) != y;
+ (x ) != y;
+ ()
+ }
+ def fun_oi(x: AnyRef, y: Int): Unit = {
+ (x: Any) == y;
+ (x ) == y;
+ (x: Any) != y;
+ (x ) != y;
+ ()
+ }
+ def fun_oo(x: AnyRef, y: AnyRef): Unit = {
+ (x: Any) == y;
+ (x ) == y;
+ (x: Any) != y;
+ (x ) != y;
+ ()
+ }
+
+}
diff --git a/test/files/neg/checksensible.check b/test/files/neg/checksensible.check
index a4cf1cfe41..27d1baeebb 100644
--- a/test/files/neg/checksensible.check
+++ b/test/files/neg/checksensible.check
@@ -7,9 +7,11 @@ checksensible.scala:5: warning: comparing values of types scala.Ordered[scala.Un
checksensible.scala:6: warning: comparing values of types scala.Unit and scala.Int using `==' will always yield false
println((c = 1) == 0)
^
+actual = class Stringfalse
checksensible.scala:8: warning: comparing values of types scala.Int and java.lang.String using `==' will always yield false
println(1 == "abc")
^
+actual = class Booleanfalse
checksensible.scala:9: warning: comparing values of types scala.Int and scala.Boolean using `!=' will always yield true
println(1 != true)
^
@@ -22,7 +24,11 @@ checksensible.scala:12: warning: comparing a fresh object using `==' will always
checksensible.scala:13: warning: comparing a fresh object using `!=' will always yield true
println(new Array(1) != new Array(1))
^
-checksensible.scala:20: warning: comparing values of types scala.Unit and scala.Int using `!=' will always yield true
+actual = trait Nullfalse
+checksensible.scala:16: warning: comparing values of types scala.Int and scala.Null using `==' will always yield false
+ if( foo.length == null ) // == 0 makes more sense, but still
+ ^
+checksensible.scala:26: warning: comparing values of types scala.Unit and scala.Int using `!=' will always yield true
while((c = in.read) != -1) {
^
-9 warnings found
+10 warnings found
diff --git a/test/files/neg/checksensible.scala b/test/files/neg/checksensible.scala
index 1a2c4425fd..23e968a6cf 100644
--- a/test/files/neg/checksensible.scala
+++ b/test/files/neg/checksensible.scala
@@ -12,6 +12,12 @@ object Test {
println(new Object == new Object)
println(new Array(1) != new Array(1))
+ val foo: Array[String] = Array("1","2","3");
+ if( foo.length == null ) // == 0 makes more sense, but still
+ Console.println("plante"); // this code leads to runtime crash
+ else
+ Console.println("plante pas");
+
def main(args: Array[String]) = {
val in = new FileInputStream(args(0))
@@ -23,4 +29,5 @@ object Test {
in.close
}
+
}