Skip to content
This repository was archived by the owner on Aug 17, 2019. It is now read-only.

Commit ec9e5d3

Browse files
committed
Remove explicit use of manifests (via ManifestHelpers)
1 parent 0017cf8 commit ec9e5d3

File tree

3 files changed

+85
-156
lines changed

3 files changed

+85
-156
lines changed

src/main/scala/com/ckkloverdos/manifest/ManifestHelpers.scala

-78
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright 2011 Christos KK Loverdos
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.ckkloverdos.convert
18+
19+
20+
import org.junit.Assert
21+
import org.junit.Test
22+
23+
/**
24+
*
25+
* @author Christos KK Loverdos <loverdos@gmail.com>.
26+
*/
27+
class TypeTest {
28+
29+
val infoList = List(
30+
(1: Byte, Manifest.Byte, Array[Byte](), typeOf[Array[Byte]]),
31+
(true, Manifest.Boolean, Array[Boolean](), typeOf[Array[Boolean]]),
32+
(1: Short, Manifest.Short, Array[Short](), typeOf[Array[Short]]),
33+
(' ', Manifest.Char, Array[Char](), typeOf[Array[Char]]),
34+
(1: Int, Manifest.Int, Array[Int](), typeOf[Array[Int]]),
35+
(1: Long, Manifest.Long, Array[Long](), typeOf[Array[Long]]),
36+
(1: Float, Manifest.Float, Array[Float](), typeOf[Array[Float]]),
37+
(1: Double, Manifest.Double, Array[Double](), typeOf[Array[Double]]) //,
38+
// ((), Manifest.Unit, Array[Unit](), manifest[Array[Unit]]) // we have a bug in scalac here...
39+
)
40+
41+
val valueList = infoList map {
42+
case (v, m, _, _) (v, m)
43+
}
44+
val arrayList = infoList map {
45+
case (_, _, av, am) (av, am)
46+
}
47+
48+
def id[A](a: A) = a
49+
50+
def _checkValue[T](value: T, expectedType: Type[_], info: String = ""): Unit = {
51+
val computedType = typeOfAny(value)
52+
Assert.assertEquals("%sType for value %s".format(info, value), expectedType, computedType)
53+
}
54+
55+
@Test
56+
def testValues: Unit = {
57+
for((value, tpe) <- valueList) {
58+
// println("Testing value %s of manifest %s".format(value, manifest))
59+
_checkValue(value, tpe)
60+
}
61+
}
62+
63+
@Test
64+
def testValues2: Unit = {
65+
val v2 = valueList map {
66+
case (v, m) => (id(v), m)
67+
}
68+
for((value, tpe) <- v2) {
69+
// println("Testing(2) value %s of manifest %s".format(value, manifest))
70+
_checkValue(value, tpe)
71+
}
72+
}
73+
74+
@Test
75+
def testNull: Unit = {
76+
_checkValue(null, typeOf[Null])
77+
}
78+
79+
@Test
80+
def testArray: Unit = {
81+
for((av, am) <- arrayList) {
82+
_checkValue(av, am)
83+
}
84+
}
85+
}

src/test/scala/com/ckkloverdos/manifest/ManifestTest.scala

-78
This file was deleted.

0 commit comments

Comments
 (0)