summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-03-22 14:57:44 +0000
committerMartin Odersky <odersky@gmail.com>2007-03-22 14:57:44 +0000
commit0196b0e057dcd62903b6635f53d2857ea182280a (patch)
treec88d8741a32cb20e871f56f480e7fd9bb62e66de /test/files
parent2dcc3776f9ba385b9b75cefba16ea27009b6eed2 (diff)
downloadscala-0196b0e057dcd62903b6635f53d2857ea182280a.tar.gz
scala-0196b0e057dcd62903b6635f53d2857ea182280a.tar.bz2
scala-0196b0e057dcd62903b6635f53d2857ea182280a.zip
(1) added readLong to Console.
(2) added print/read methods to Predef (3) added warnings for non-sensical comparisons
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/checksensible.check28
-rw-r--r--test/files/neg/checksensible.scala26
2 files changed, 54 insertions, 0 deletions
diff --git a/test/files/neg/checksensible.check b/test/files/neg/checksensible.check
new file mode 100644
index 0000000000..a4cf1cfe41
--- /dev/null
+++ b/test/files/neg/checksensible.check
@@ -0,0 +1,28 @@
+checksensible.scala:4: warning: comparing values of types scala.Ordered[scala.Unit] and scala.Unit using `>' will always yield false
+ println((c = 1) > 0)
+ ^
+checksensible.scala:5: warning: comparing values of types scala.Ordered[scala.Unit] and scala.Unit using `<=' will always yield true
+ println((c = 1) <= 0)
+ ^
+checksensible.scala:6: warning: comparing values of types scala.Unit and scala.Int using `==' will always yield false
+ println((c = 1) == 0)
+ ^
+checksensible.scala:8: warning: comparing values of types scala.Int and java.lang.String using `==' will always yield false
+ println(1 == "abc")
+ ^
+checksensible.scala:9: warning: comparing values of types scala.Int and scala.Boolean using `!=' will always yield true
+ println(1 != true)
+ ^
+checksensible.scala:11: warning: comparing a fresh object using `==' will always yield false
+ println(((x: int) => x + 1) == null)
+ ^
+checksensible.scala:12: warning: comparing a fresh object using `==' will always yield false
+ println(new Object == new Object)
+ ^
+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
+ while((c = in.read) != -1) {
+ ^
+9 warnings found
diff --git a/test/files/neg/checksensible.scala b/test/files/neg/checksensible.scala
new file mode 100644
index 0000000000..1a2c4425fd
--- /dev/null
+++ b/test/files/neg/checksensible.scala
@@ -0,0 +1,26 @@
+import java.io._
+object Test {
+ var c = 0
+ println((c = 1) > 0)
+ println((c = 1) <= 0)
+ println((c = 1) == 0)
+
+ println(1 == "abc")
+ println(1 != true)
+
+ println(((x: int) => x + 1) == null)
+ println(new Object == new Object)
+ println(new Array(1) != new Array(1))
+
+ def main(args: Array[String]) = {
+ val in = new FileInputStream(args(0))
+
+ var c = 0
+
+ while((c = in.read) != -1) {
+ Console.print(c.toChar)
+ }
+
+ in.close
+ }
+}