blob: 9a58b5cca298bff439eb664523c335cf7c31a19c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package scala.scalajs.sbtplugin.test.env
import scala.scalajs.sbtplugin.env.nodejs.NodeJSEnv
import org.junit.Test
class NodeJSTest extends JSEnvTest with ComTests {
protected def newJSEnv = new NodeJSEnv
/** Node.js strips double percentage signs - #500 */
@Test
def percentageTest = {
val counts = 1 to 15
val argcs = 1 to 3
val strings = counts.map("%" * _)
val strlists = for {
count <- argcs
string <- strings
} yield List.fill(count)(string)
val codes = for {
strlist <- strlists
} yield {
val args = strlist.map(s => s""""$s"""").mkString(", ")
s"console.log($args);\n"
}
val result = strlists.map(_.mkString(" ") + "\n").mkString("")
codes.mkString("").hasOutput(result)
}
/** Node.js console.log hack didn't allow to log non-Strings - #561 */
@Test
def nonStringTest = {
"""
console.log(1);
console.log(undefined);
console.log(null);
console.log({});
console.log([1,2]);
""" hasOutput
"""|1
|undefined
|null
|[object Object]
|1,2
|""".stripMargin
}
}
|