summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorSeth Tisue <seth@tisue.net>2017-02-16 13:23:08 -0800
committerGitHub <noreply@github.com>2017-02-16 13:23:08 -0800
commit955b779b63d16ab3d2d24b454374c55e9d06c228 (patch)
tree54d5c176ffa375debb265b0784ea9c298c53081a /test/files/neg
parent7b4567627c2b308866251b88aee3c2e6c72941f1 (diff)
parenta262aaba15effce48fdba95910bef367f89cafca (diff)
downloadscala-955b779b63d16ab3d2d24b454374c55e9d06c228.tar.gz
scala-955b779b63d16ab3d2d24b454374c55e9d06c228.tar.bz2
scala-955b779b63d16ab3d2d24b454374c55e9d06c228.zip
Merge pull request #5648 from som-snytt/issue/10148
SI-10148 Follow Java for float literals
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/literals.check14
-rw-r--r--test/files/neg/literals.scala13
2 files changed, 25 insertions, 2 deletions
diff --git a/test/files/neg/literals.check b/test/files/neg/literals.check
index 148a9346c5..79b6d47782 100644
--- a/test/files/neg/literals.check
+++ b/test/files/neg/literals.check
@@ -19,6 +19,18 @@ literals.scala:23: error: missing integer number
literals.scala:27: error: Decimal integer literals may not have a leading zero. (Octal syntax is obsolete.)
def tooManyZeros: Int = 00 // line 26: no leading zero
^
+literals.scala:40: error: floating point number too small
+ def tooTiny: Float = { 0.7e-45f } // floating point number too small
+ ^
+literals.scala:42: error: double precision floating point number too small
+ def twoTiny: Double = { 2.0e-324 } // double precision floating point number too small
+ ^
+literals.scala:44: error: floating point number too large
+ def tooHuge: Float = { 3.4028236E38f } // floating point number too large
+ ^
+literals.scala:46: error: double precision floating point number too large
+ def twoHuge: Double = { 1.7976931348623159e308 } // double precision floating point number too large
+ ^
literals.scala:14: error: identifier expected but '}' found.
def orphanDot: Int = { 9. } // line 12: ident expected
^
@@ -37,4 +49,4 @@ literals.scala:29: error: ';' expected but 'def' found.
literals.scala:33: error: identifier expected but 'def' found.
def zeroOfNineDot: Int = 09. // line 32: malformed integer, ident expected
^
-13 errors found
+17 errors found
diff --git a/test/files/neg/literals.scala b/test/files/neg/literals.scala
index 3df7f0b408..22d5d9acd1 100644
--- a/test/files/neg/literals.scala
+++ b/test/files/neg/literals.scala
@@ -1,6 +1,6 @@
/* This took me literally all day.
-*/
+ */
trait RejectedLiterals {
def missingHex: Int = { 0x } // line 4: was: not reported, taken as zero
@@ -34,3 +34,14 @@ trait Braceless {
def noHexFloat: Double = 0x1.2 // line 34: ';' expected but double literal found.
}
+
+trait MoreSadness {
+
+ def tooTiny: Float = { 0.7e-45f } // floating point number too small
+
+ def twoTiny: Double = { 2.0e-324 } // double precision floating point number too small
+
+ def tooHuge: Float = { 3.4028236E38f } // floating point number too large
+
+ def twoHuge: Double = { 1.7976931348623159e308 } // double precision floating point number too large
+}