Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 549d959

Browse files
committed
Accept 0 arguments
1 parent e675c7a commit 549d959

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

app/nodejs-v10/src/test/scala/io/scalajs/nodejs/console_module/ConsoleTest.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,33 @@ class ConsoleTest extends AnyFunSpec with BeforeAndAfterEach {
1313
if (Fs.existsSync(logFileName)) Fs.unlinkSync(logFileName)
1414
}
1515

16+
it("should accept no-arguments") {
17+
Console.log()
18+
Console.info()
19+
Console.warn()
20+
Console.debug()
21+
Console.error()
22+
Console.trace()
23+
}
24+
25+
it("should accept single arguments") {
26+
Console.log("a")
27+
Console.info("a")
28+
Console.warn("a")
29+
Console.debug("a")
30+
Console.error("a")
31+
Console.trace("")
32+
}
33+
34+
it("should accept multiple arguments") {
35+
Console.log("a", 1)
36+
Console.info("a", 2)
37+
Console.warn("a", 3)
38+
Console.debug("a", 4)
39+
Console.error("a", 5)
40+
Console.trace("", 6)
41+
}
42+
1643
it("have table added in v10.0.0") {
1744
Console.table(js.Array("x", "y"))
1845
}

app/nodejs-v14/src/main/scala/io/scalajs/nodejs/console_module/Console.scala

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ class Console protected () extends js.Object {
7777

7878
/**
7979
* The `console.debug()` function is an alias for `console.log()`.
80-
* @param message
81-
* @param optionalParams
80+
* @param args
8281
*/
83-
def debug(message: js.Any, optionalParams: Any*): Unit = js.native
82+
def debug(args: js.Any*): Unit = js.native
8483

8584
/**
8685
* Uses [[io.scalajs.nodejs.util.Util.inspect()]] on `obj` and prints the resulting string to `stdout`.
@@ -104,10 +103,9 @@ class Console protected () extends js.Object {
104103
* is called on each argument and the resulting string values are concatenated. See [[io.scalajs.nodejs.util.Util.format()]]
105104
* for more information.
106105
*
107-
* @param message
108-
* @param optionalParams
106+
* @param args
109107
*/
110-
def error(message: js.Any, optionalParams: Any*): Unit = js.native
108+
def error(args: js.Any*): Unit = js.native
111109

112110
/**
113111
* Increases indentation of subsequent lines by two spaces.
@@ -132,14 +130,14 @@ class Console protected () extends js.Object {
132130
/**
133131
* The `console.info()` function is an alias for [[log()]].
134132
*/
135-
def info(message: js.Any, optionalParams: js.Any*): Unit = js.native
133+
def info(args: js.Any*): Unit = js.native
136134

137135
/**
138136
* Prints to `stdout` with newline.
139137
* Multiple arguments can be passed, with the first used as the primary message and all additional used as
140138
* substitution values similar to `printf(3)` (the arguments are all passed to `util.format()`).
141139
*/
142-
def log(message: js.Any, optionalParams: Any*): Unit = js.native
140+
def log(args: js.Any*): Unit = js.native
143141

144142
/**
145143
* Try to construct a table with the columns of the properties of `tabularData` (or use `properties`) and
@@ -176,12 +174,12 @@ class Console protected () extends js.Object {
176174
* Prints to `stderr` the string `'Trace: '`, followed by the [[io.scalajs.nodejs.util.Util.format()]] formatted
177175
* message and stack trace to the current position in the code.
178176
*/
179-
def trace(message: js.Any, optionalParams: js.Any*): Unit = js.native
177+
def trace(args: js.Any*): Unit = js.native
180178

181179
/**
182180
* The `console.warn()` function is an alias for [[error()]
183181
*/
184-
def warn(message: js.Any, optionalParams: js.Any*): Unit = js.native
182+
def warn(args: js.Any*): Unit = js.native
185183

186184
/**
187185
* This method does not display anything unless used in the inspector.

0 commit comments

Comments
 (0)