From dca4bd8ad6a2bac26ec9fdc84efd74007805f104 Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 26 Sep 2019 06:00:49 +0900 Subject: [PATCH 1/3] Assimilate package names with main code so easy to import --- app/current/src/main/scala/io/scalajs/nodejs/Process.scala | 2 +- .../scala/{ => io/scalajs}/nodejs/buffer/BufferTest.scala | 2 +- .../src/test/scala/{ => io/scalajs}/nodejs/ConsoleTest.scala | 2 +- .../scala/{ => io/scalajs}/nodejs/assertion/AssertTest.scala | 2 +- .../{ => io/scalajs}/nodejs/crypto/CertificateTest.scala | 0 .../scala/{ => io/scalajs}/nodejs/crypto/CryptoTest.scala | 0 .../test/scala/{ => io/scalajs}/nodejs/path/PathTest.scala | 0 .../test/scala/{ => io/scalajs}/nodejs/util/UtilTest.scala | 0 .../src/test/scala/{ => io/scalajs}/nodejs/AssertTest.scala | 0 .../src/test/scala/{ => io/scalajs}/nodejs/ConsoleTest.scala | 2 +- .../src/test/scala/{ => io/scalajs}/nodejs/ProcessTest.scala | 0 .../scala/{ => io/scalajs}/nodejs/StringDecoderTest.scala | 0 .../test/scala/{ => io/scalajs}/nodejs/TestEnvironment.scala | 3 ++- .../scala/{ => io/scalajs}/nodejs/buffer/BufferTest.scala | 5 ++--- .../nodejs/child_process/ChildProcessAsyncTest.scala | 0 .../scalajs}/nodejs/child_process/ChildProcessTest.scala | 0 .../scala/{ => io/scalajs}/nodejs/cluster/ClusterTest.scala | 0 .../{ => io/scalajs}/nodejs/crypto/CertificateTest.scala | 0 .../scala/{ => io/scalajs}/nodejs/crypto/CryptoTest.scala | 0 .../scala/{ => io/scalajs}/nodejs/dns/DNSAsyncTest.scala | 0 .../src/test/scala/{ => io/scalajs}/nodejs/dns/DNSTest.scala | 0 .../{ => io/scalajs}/nodejs/events/EventEmitterTest.scala | 0 .../test/scala/{ => io/scalajs}/nodejs/fs/FsAsyncTest.scala | 0 .../src/test/scala/{ => io/scalajs}/nodejs/fs/FsTest.scala | 0 .../scala/{ => io/scalajs}/nodejs/fs/ReadStreamTest.scala | 0 .../test/scala/{ => io/scalajs}/nodejs/http/HttpTest.scala | 0 .../src/test/scala/{ => io/scalajs}/nodejs/net/NetTest.scala | 0 .../src/test/scala/{ => io/scalajs}/nodejs/os/OSTest.scala | 0 .../test/scala/{ => io/scalajs}/nodejs/path/PathTest.scala | 0 .../scalajs}/nodejs/querystring/QueryStringTest.scala | 0 .../{ => io/scalajs}/nodejs/readline/ReadlineTest.scala | 0 .../src/test/scala/{ => io/scalajs}/nodejs/tty/TTYTest.scala | 0 .../scala/{ => io/scalajs}/nodejs/url/URLObjectTest.scala | 0 .../{ => io/scalajs}/nodejs/url/URLSearchParamsTest.scala | 0 .../src/test/scala/{ => io/scalajs}/nodejs/url/URLTest.scala | 0 .../test/scala/{ => io/scalajs}/nodejs/util/UtilTest.scala | 0 .../src/test/scala/{ => io/scalajs}/nodejs/vm/VMTest.scala | 0 .../test/scala/{ => io/scalajs}/nodejs/zlib/ZlibTest.scala | 0 38 files changed, 9 insertions(+), 9 deletions(-) rename app/current/src/test/scala/{ => io/scalajs}/nodejs/buffer/BufferTest.scala (93%) rename app/nodejs-v10/src/test/scala/{ => io/scalajs}/nodejs/ConsoleTest.scala (97%) rename app/nodejs-v10/src/test/scala/{ => io/scalajs}/nodejs/assertion/AssertTest.scala (91%) rename app/nodejs-v10/src/test/scala/{ => io/scalajs}/nodejs/crypto/CertificateTest.scala (100%) rename app/nodejs-v10/src/test/scala/{ => io/scalajs}/nodejs/crypto/CryptoTest.scala (100%) rename app/nodejs-v10/src/test/scala/{ => io/scalajs}/nodejs/path/PathTest.scala (100%) rename app/nodejs-v10/src/test/scala/{ => io/scalajs}/nodejs/util/UtilTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/AssertTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/ConsoleTest.scala (97%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/ProcessTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/StringDecoderTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/TestEnvironment.scala (95%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/buffer/BufferTest.scala (97%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/child_process/ChildProcessAsyncTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/child_process/ChildProcessTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/cluster/ClusterTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/crypto/CertificateTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/crypto/CryptoTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/dns/DNSAsyncTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/dns/DNSTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/events/EventEmitterTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/fs/FsAsyncTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/fs/FsTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/fs/ReadStreamTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/http/HttpTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/net/NetTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/os/OSTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/path/PathTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/querystring/QueryStringTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/readline/ReadlineTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/tty/TTYTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/url/URLObjectTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/url/URLSearchParamsTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/url/URLTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/util/UtilTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/vm/VMTest.scala (100%) rename app/nodejs-v8/src/test/scala/{ => io/scalajs}/nodejs/zlib/ZlibTest.scala (100%) diff --git a/app/current/src/main/scala/io/scalajs/nodejs/Process.scala b/app/current/src/main/scala/io/scalajs/nodejs/Process.scala index df5264d8c..f227e9d59 100644 --- a/app/current/src/main/scala/io/scalajs/nodejs/Process.scala +++ b/app/current/src/main/scala/io/scalajs/nodejs/Process.scala @@ -144,7 +144,7 @@ trait Process extends IEventEmitter { * v0.8 allowed for longer process title strings by also overwriting the environ memory but that was * potentially insecure/confusing in some (rather obscure) cases. */ - var title: js.Any = js.native + var title: String = js.native /** * A compiled-in property that exposes NODE_VERSION. diff --git a/app/current/src/test/scala/nodejs/buffer/BufferTest.scala b/app/current/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala similarity index 93% rename from app/current/src/test/scala/nodejs/buffer/BufferTest.scala rename to app/current/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala index fa820bc6f..292110d8f 100644 --- a/app/current/src/test/scala/nodejs/buffer/BufferTest.scala +++ b/app/current/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala @@ -1,4 +1,4 @@ -package nodejs.buffer +package io.scalajs.nodejs.buffer import io.scalajs.nodejs.buffer.Buffer import org.scalatest.FunSpec diff --git a/app/nodejs-v10/src/test/scala/nodejs/ConsoleTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/ConsoleTest.scala similarity index 97% rename from app/nodejs-v10/src/test/scala/nodejs/ConsoleTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/ConsoleTest.scala index b58940d3a..1381d6c30 100644 --- a/app/nodejs-v10/src/test/scala/nodejs/ConsoleTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/ConsoleTest.scala @@ -1,4 +1,4 @@ -package nodejs +package io.scalajs.nodejs import io.scalajs.nodejs.console_module.{Console, ConsoleOptions} import io.scalajs.nodejs.fs.Fs diff --git a/app/nodejs-v10/src/test/scala/nodejs/assertion/AssertTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/assertion/AssertTest.scala similarity index 91% rename from app/nodejs-v10/src/test/scala/nodejs/assertion/AssertTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/assertion/AssertTest.scala index c8d3d0405..783f74f16 100644 --- a/app/nodejs-v10/src/test/scala/nodejs/assertion/AssertTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/assertion/AssertTest.scala @@ -1,4 +1,4 @@ -package nodejs.assertion +package io.scalajs.nodejs.assertion import org.scalatest.FunSpec import io.scalajs.nodejs.{ Assert => NodeAssert } diff --git a/app/nodejs-v10/src/test/scala/nodejs/crypto/CertificateTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/nodejs/crypto/CertificateTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala diff --git a/app/nodejs-v10/src/test/scala/nodejs/crypto/CryptoTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/nodejs/crypto/CryptoTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala diff --git a/app/nodejs-v10/src/test/scala/nodejs/path/PathTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/nodejs/path/PathTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala diff --git a/app/nodejs-v10/src/test/scala/nodejs/util/UtilTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala similarity index 100% rename from app/nodejs-v10/src/test/scala/nodejs/util/UtilTest.scala rename to app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/AssertTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/AssertTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/AssertTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/AssertTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/ConsoleTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/ConsoleTest.scala similarity index 97% rename from app/nodejs-v8/src/test/scala/nodejs/ConsoleTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/ConsoleTest.scala index fd9ec6482..ae93da754 100644 --- a/app/nodejs-v8/src/test/scala/nodejs/ConsoleTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/ConsoleTest.scala @@ -1,4 +1,4 @@ -package nodejs +package io.scalajs.nodejs import io.scalajs.nodejs.console_module.Console import io.scalajs.nodejs.fs.Fs diff --git a/app/nodejs-v8/src/test/scala/nodejs/ProcessTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/ProcessTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/ProcessTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/ProcessTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/StringDecoderTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/StringDecoderTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/TestEnvironment.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala similarity index 95% rename from app/nodejs-v8/src/test/scala/nodejs/TestEnvironment.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala index 11b991d8d..55df5dd62 100644 --- a/app/nodejs-v8/src/test/scala/nodejs/TestEnvironment.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala @@ -1,4 +1,5 @@ -package nodejs +package io.scalajs.nodejs + import io.scalajs.nodejs.buffer.Buffer import io.scalajs.nodejs.child_process.ChildProcess diff --git a/app/nodejs-v8/src/test/scala/nodejs/buffer/BufferTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala similarity index 97% rename from app/nodejs-v8/src/test/scala/nodejs/buffer/BufferTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala index 1254acb77..57e58cb64 100644 --- a/app/nodejs-v8/src/test/scala/nodejs/buffer/BufferTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala @@ -1,12 +1,11 @@ package io.scalajs.nodejs.buffer import io.scalajs.collection.Iterator.Entry -import io.scalajs.nodejs.buffer -import nodejs.TestEnvironment +import io.scalajs.nodejs.{ TestEnvironment, buffer } import org.scalatest.FunSpec import scala.scalajs.js -import scala.scalajs.js.typedarray.{ArrayBuffer, DataView, Uint8Array} +import scala.scalajs.js.typedarray.{ ArrayBuffer, DataView, Uint8Array } /** * Buffer Tests diff --git a/app/nodejs-v8/src/test/scala/nodejs/child_process/ChildProcessAsyncTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessAsyncTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/child_process/ChildProcessAsyncTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessAsyncTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/child_process/ChildProcessTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/child_process/ChildProcessTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/cluster/ClusterTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/cluster/ClusterTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/crypto/CertificateTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/crypto/CertificateTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CertificateTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/crypto/CryptoTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/crypto/CryptoTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/dns/DNSAsyncTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/dns/DNSAsyncTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/dns/DNSTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/dns/DNSTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/events/EventEmitterTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/events/EventEmitterTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/fs/FsAsyncTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/fs/FsAsyncTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/fs/FsTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/fs/FsTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/fs/ReadStreamTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/fs/ReadStreamTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/http/HttpTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/http/HttpTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/net/NetTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/net/NetTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/net/NetTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/net/NetTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/os/OSTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/os/OSTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/os/OSTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/os/OSTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/path/PathTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/path/PathTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/path/PathTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/path/PathTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/querystring/QueryStringTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/querystring/QueryStringTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/querystring/QueryStringTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/readline/ReadlineTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/readline/ReadlineTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/tty/TTYTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/tty/TTYTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/tty/TTYTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/url/URLObjectTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/url/URLObjectTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/url/URLSearchParamsTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/url/URLSearchParamsTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/url/URLTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/url/URLTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/util/UtilTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/util/UtilTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/vm/VMTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/vm/VMTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala diff --git a/app/nodejs-v8/src/test/scala/nodejs/zlib/ZlibTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala similarity index 100% rename from app/nodejs-v8/src/test/scala/nodejs/zlib/ZlibTest.scala rename to app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala From f2e8b2926dab17f07ec4f40e8e32f4bb0a856e91 Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 26 Sep 2019 06:04:39 +0900 Subject: [PATCH 2/3] Use strict equality operator === and !==. --- .../io/scalajs/nodejs/path/PathTest.scala | 4 +- .../io/scalajs/nodejs/util/UtilTest.scala | 2 +- .../io/scalajs/nodejs/buffer/BufferTest.scala | 56 +++++++++---------- .../io/scalajs/nodejs/crypto/CryptoTest.scala | 4 +- .../nodejs/events/EventEmitterTest.scala | 2 +- .../io/scalajs/nodejs/fs/FsAsyncTest.scala | 2 +- .../scala/io/scalajs/nodejs/fs/FsTest.scala | 6 +- .../io/scalajs/nodejs/fs/ReadStreamTest.scala | 12 ++-- .../io/scalajs/nodejs/http/HttpTest.scala | 2 +- .../io/scalajs/nodejs/path/PathTest.scala | 16 +++--- .../io/scalajs/nodejs/url/URLObjectTest.scala | 4 +- .../nodejs/url/URLSearchParamsTest.scala | 6 +- .../io/scalajs/nodejs/util/UtilTest.scala | 8 +-- .../scala/io/scalajs/nodejs/vm/VMTest.scala | 4 +- .../io/scalajs/nodejs/zlib/ZlibTest.scala | 2 +- 15 files changed, 65 insertions(+), 65 deletions(-) diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala index 57697cca9..79a0baf3c 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/path/PathTest.scala @@ -6,8 +6,8 @@ import org.scalatest.FunSpec class PathTest extends FunSpec { describe("Path") { it("supports join()") { - assert(Path.win32.toNamespacedPath("c:\\foo\\bar") == "\\\\?\\c:\\foo\\bar") - assert(Path.posix.toNamespacedPath("c:\\foo\\bar") == "c:\\foo\\bar") + assert(Path.win32.toNamespacedPath("c:\\foo\\bar") === "\\\\?\\c:\\foo\\bar") + assert(Path.posix.toNamespacedPath("c:\\foo\\bar") === "c:\\foo\\bar") } } } diff --git a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala index 5591c7d62..f749ebbff 100644 --- a/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala +++ b/app/nodejs-v10/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala @@ -21,7 +21,7 @@ class UtilTest extends FunSpec { } it("have inspect.custom added in v10.12.0") { - assert(Util.inspect.custom != null) + assert(Util.inspect.custom !== null) } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala index 57e58cb64..1e16daee7 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala @@ -1,11 +1,11 @@ package io.scalajs.nodejs.buffer import io.scalajs.collection.Iterator.Entry -import io.scalajs.nodejs.{ TestEnvironment, buffer } +import io.scalajs.nodejs.{TestEnvironment, buffer} import org.scalatest.FunSpec import scala.scalajs.js -import scala.scalajs.js.typedarray.{ ArrayBuffer, DataView, Uint8Array } +import scala.scalajs.js.typedarray.{ArrayBuffer, DataView, Uint8Array} /** * Buffer Tests @@ -19,11 +19,11 @@ class BufferTest extends FunSpec { val buf2 = Buffer.from("BCD") val buf3 = Buffer.from("ABCD") - assert(buf1.compare(buf1) == 0) - assert(buf1.compare(buf2) == -1) - assert(buf1.compare(buf3) == -1) - assert(buf2.compare(buf1) == 1) - assert(buf2.compare(buf3) == 1) + assert(buf1.compare(buf1) === 0) + assert(buf1.compare(buf2) === -1) + assert(buf1.compare(buf3) === -1) + assert(buf2.compare(buf1) === 1) + assert(buf2.compare(buf3) === 1) } it("should support iterating entries [classic]") { @@ -51,21 +51,21 @@ class BufferTest extends FunSpec { import scala.scalajs.js.typedarray.Int8Array val nodeBuffer = Buffer.from(js.Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)) val typedarray = new Int8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.length) - assert(typedarray.mkString == new Int8Array(js.Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)).mkString) + assert(typedarray.mkString === new Int8Array(js.Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)).mkString) } it("should support byteLength for specific types") { - assert(Buffer.byteLength("\u00bd + \u00bc = \u00be") == 12) - assert(Buffer.byteLength("\u00bd + \u00bc = \u00be", "utf8") == 12) - assert(Buffer.byteLength(Buffer.alloc(12)) == 12) - assert(Buffer.byteLength(new Uint8Array(12)) == 12) - assert(Buffer.byteLength(new DataView(new ArrayBuffer(12))) == 12) - assert(Buffer.byteLength(new ArrayBuffer(12)) == 12) + assert(Buffer.byteLength("\u00bd + \u00bc = \u00be") === 12) + assert(Buffer.byteLength("\u00bd + \u00bc = \u00be", "utf8") === 12) + assert(Buffer.byteLength(Buffer.alloc(12)) === 12) + assert(Buffer.byteLength(new Uint8Array(12)) === 12) + assert(Buffer.byteLength(new DataView(new ArrayBuffer(12))) === 12) + assert(Buffer.byteLength(new ArrayBuffer(12)) === 12) } it("should support fill") { val otherBuf = Buffer.from("abcdef") - assert(Buffer.alloc(10).fill(otherBuf).toString() == "abcdefabcd") + assert(Buffer.alloc(10).fill(otherBuf).toString() === "abcdefabcd") } } @@ -82,28 +82,28 @@ class BufferTest extends FunSpec { val bufC = bufA + bufB info(s"bufC => ${bufC.toString()}, length = ${bufC.byteLength()}") - assert(bufA.toString() == "Hello ") - assert(bufB.toString() == "World") - assert(bufC.byteLength() == 11) + assert(bufA.toString() === "Hello ") + assert(bufB.toString() === "World") + assert(bufC.byteLength() === 11) } it("should create buffers from buffers") { val buffer = Buffer.from("hello") - assert(Buffer.from(buffer).toString() == "hello") + assert(Buffer.from(buffer).toString() === "hello") // TODO: when Scala.js added TypedArray.from // val uints = Uint8Array.from(???) - // assert(Buffer.from(uints).toString() == "worlds") + // assert(Buffer.from(uints).toString() ==="worlds") } it("should support concat") { val buffers = js.Array(Buffer.from("abc"), Buffer.from("def"), Buffer.from("ghijk")) - assert(Buffer.compare(Buffer.concat(buffers), Buffer.from("abcdefghijk")) == 0) - assert(Buffer.compare(Buffer.concat(buffers, 5), Buffer.from("abcde")) == 0) + assert(Buffer.compare(Buffer.concat(buffers), Buffer.from("abcdefghijk")) === 0) + assert(Buffer.compare(Buffer.concat(buffers, 5), Buffer.from("abcde")) === 0) val uints: js.Array[Uint8Array] = js.Array(Buffer.from("abc"), Buffer.from("def"), Buffer.from("ghijk")) - assert(Buffer.compare(Buffer.concat(uints), Buffer.from("abcdefghijk")) == 0) - assert(Buffer.compare(Buffer.concat(uints, 5), Buffer.from("abcde")) == 0) + assert(Buffer.compare(Buffer.concat(uints), Buffer.from("abcdefghijk")) === 0) + assert(Buffer.compare(Buffer.concat(uints, 5), Buffer.from("abcde")) === 0) } it("should support isBufrer") { @@ -129,12 +129,12 @@ class BufferTest extends FunSpec { describe("module members") { it("should support transcode") { // package object method - assert(buffer.transcode(Buffer.from("hello"), "utf8", "ascii").toString("ascii") == "hello") - assert(buffer.transcode(Buffer.from("€"), "utf8", "ascii").toString("ascii") == "?") + assert(buffer.transcode(Buffer.from("hello"), "utf8", "ascii").toString("ascii") === "hello") + assert(buffer.transcode(Buffer.from("€"), "utf8", "ascii").toString("ascii") === "?") // extension method - assert(Buffer.transcode(Buffer.from("hello"), "utf8", "ascii").toString("ascii") == "hello") - assert(Buffer.transcode(Buffer.from("€"), "utf8", "ascii").toString("ascii") == "?") + assert(Buffer.transcode(Buffer.from("hello"), "utf8", "ascii").toString("ascii") === "hello") + assert(Buffer.transcode(Buffer.from("€"), "utf8", "ascii").toString("ascii") === "?") } it("should support fields") { diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala index a8d492b03..9aec1d0d2 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/crypto/CryptoTest.scala @@ -15,14 +15,14 @@ class CryptoTest extends FunSpec with MustMatchers { val hasher = Crypto.createHash("md5") hasher.update(text) val buffer = hasher.digest() - assert(buffer.toHexString == "b10a8db164e0754105b7a99be72e3fe5") + assert(buffer.toHexString === "b10a8db164e0754105b7a99be72e3fe5") } it("should be able to create a SHA256 hash from a string") { val hasher = Crypto.createHash("sha256") hasher.update(text) val buffer = hasher.digest() - assert(buffer.toHexString == "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e") + assert(buffer.toHexString === "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e") } it("should be able to hash passwords with pbkdf2Sync") { diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala index 845d2946e..0111f8caf 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala @@ -50,7 +50,7 @@ class EventEmitterTest extends FunSpec { val myEmitter = new EventEmitter() myEmitter.on("event", () => {}) myEmitter.on("event", () => {}) - assert(myEmitter.listenerCount("event") == 2) + assert(myEmitter.listenerCount("event") === 2) } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala index 4ef9a6522..4366f920c 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala @@ -26,7 +26,7 @@ class FsAsyncTest extends AsyncFunSpec with BeforeAndAfterEach { existsAfterUnlink <- Fs.existsFuture(file) } yield { assert(exists) - assert(readBuffer.asInstanceOf[Buffer].toString() == "content") + assert(readBuffer.asInstanceOf[Buffer].toString() === "content") assert(!existsAfterUnlink) } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala index 70563702b..5e6e82101 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala @@ -45,7 +45,7 @@ class FsTest extends FunSpec { info("Comparing file sizes:") info(s"$file1 is ${Fs.statSync(file1).size} bytes") info(s"$file2 is ${Fs.statSync(file2).size} bytes") - assert(Fs.statSync(file1).size == Fs.statSync(file2).size) + assert(Fs.statSync(file1).size === Fs.statSync(file2).size) info("should rename the file") Fs.renameSync(file2, file3) @@ -70,13 +70,13 @@ class FsTest extends FunSpec { info("Comparing file sizes:") info(s"$file1 is ${Fs.statSync(file1).size} bytes") info(s"$file2 is ${Fs.statSync(file2).size} bytes") - assert(Fs.statSync(file1).size == Fs.statSync(file2).size) + assert(Fs.statSync(file1).size === Fs.statSync(file2).size) } } it("support access") { Fs.access("./package.json", err => { - assert(err == null) + assert(err === null) }) } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala index 619206cc8..c3fadfdaf 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/ReadStreamTest.scala @@ -12,17 +12,17 @@ class FsClassesTest extends FunSpec { describe("ReadStream") { it("supports constructor(") { - assert(new ReadStream("package.json") != null) - assert(new ReadStream(Buffer.from("package.json")) != null) - assert(new ReadStream(new URL(s"file:///${dirname}/package.json")) != null) + assert(new ReadStream("package.json") !== null) + assert(new ReadStream(Buffer.from("package.json")) !== null) + assert(new ReadStream(new URL(s"file:///${dirname}/package.json")) !== null) } } describe("WriteStream") { it("supports constructor") { - assert(new WriteStream("package.json") != null) - assert(new WriteStream(Buffer.from("package.json")) != null) - assert(new WriteStream(new URL(s"file:///${dirname}/package.json")) != null) + assert(new WriteStream("package.json") !== null) + assert(new WriteStream(Buffer.from("package.json")) !== null) + assert(new WriteStream(new URL(s"file:///${dirname}/package.json")) !== null) } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala index 1678e1c24..1dc7efbd8 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/http/HttpTest.scala @@ -19,7 +19,7 @@ class HttpTest extends FunSpec { response.write("Hello World") response.end() }) - assert(server != null) + assert(server !== null) // don't listen on a port //server.listen(58888) diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/path/PathTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/path/PathTest.scala index 744a46042..baf0cfbd8 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/path/PathTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/path/PathTest.scala @@ -10,22 +10,22 @@ class PathTest extends FunSpec { describe("Path") { it("supports basename()") { - assert(Path.basename("/foo/bar/baz/asdf/quux.html") == "quux.html") - assert(Path.basename("/foo/bar/baz/asdf/quux.html", ".html") == "quux") + assert(Path.basename("/foo/bar/baz/asdf/quux.html") === "quux.html") + assert(Path.basename("/foo/bar/baz/asdf/quux.html", ".html") === "quux") } it("supports posix.basename()") { - assert(Path.posix.basename("C:\\temp\\data.txt") == "C:\\temp\\data.txt") - assert(Path.posix.basename("/temp/data.txt") == "data.txt") + assert(Path.posix.basename("C:\\temp\\data.txt") === "C:\\temp\\data.txt") + assert(Path.posix.basename("/temp/data.txt") === "data.txt") } it("supports win32.basename()") { - assert(Path.win32.basename("C:\\temp\\data.txt") == "data.txt") - assert(Path.win32.basename("/temp/data.txt") == "data.txt") + assert(Path.win32.basename("C:\\temp\\data.txt") === "data.txt") + assert(Path.win32.basename("/temp/data.txt") === "data.txt") } it("supports format()") { - assert(Path.format(new PathObject(root = "/", base = "file.txt")) == "/file.txt") + assert(Path.format(new PathObject(root = "/", base = "file.txt")) === "/file.txt") } it("supports isAbsolute()") { @@ -36,7 +36,7 @@ class PathTest extends FunSpec { } it("supports join()") { - assert(Path.join("/foo", "bar", "baz/asdf", "quux", "..") == "/foo/bar/baz/asdf") + assert(Path.join("/foo", "bar", "baz/asdf", "quux", "..") === "/foo/bar/baz/asdf") } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala index e8d173715..d459947b9 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala @@ -17,7 +17,7 @@ class URLObjectTest extends FunSpec { it("should break down URLs into components") { assert( - urlObject.toJson == """{"protocol":"https:","slashes":true,"auth":null,"host":"www.google.com","port":null,"hostname":"www.google.com","hash":"#q=node","search":"?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","query":"sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","pathname":"/webhp","path":"/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","href":"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node"}""" + urlObject.toJson === """{"protocol":"https:","slashes":true,"auth":null,"host":"www.google.com","port":null,"hostname":"www.google.com","hash":"#q=node","search":"?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","query":"sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","pathname":"/webhp","path":"/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","href":"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node"}""" ) } @@ -30,7 +30,7 @@ class URLObjectTest extends FunSpec { } it("should reconstituted the URL to match the original") { - assert(URL.format(urlObject) == originalUrl) + assert(URL.format(urlObject) === originalUrl) } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala index 195f3f90f..feae80468 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala @@ -15,10 +15,10 @@ class URLSearchParamsTest extends FunSpec { it("should parse the string as a query string") { val params = new URLSearchParams("user=abc&query=xyz") info(params.get("user")) // Prints "abc" - assert(params.get("user") == "abc") + assert(params.get("user") === "abc") info(params.toString) // Prints "user=abc&query=xyz" - assert(params.toString == "user=abc&query=xyz") + assert(params.toString === "user=abc&query=xyz") } it("should parse the dictionary/object as a query string") { @@ -29,7 +29,7 @@ class URLSearchParamsTest extends FunSpec { ) ) info(params.getAll("query").mkString(", ")) // Prints [ "first,second" ] - assert(params.getAll("query").toSeq == Seq("first,second")) + assert(params.getAll("query").toSeq === Seq("first,second")) } it("should iterates over each name-value pair in the query and invokes the given function") { diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala index afee3aa72..840b0de80 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/util/UtilTest.scala @@ -5,13 +5,13 @@ import org.scalatest.FunSpec class UtilTest extends FunSpec { it("have inspect object") { - assert(Util.inspect != null) - assert(Util.inspect.defaultOptions != null) - assert(Util.inspect.styles != null) + assert(Util.inspect !== null) + assert(Util.inspect.defaultOptions !== null) + assert(Util.inspect.styles !== null) } it("have promisify") { - assert(Util.promisify.custom != null) + assert(Util.promisify.custom !== null) } it("have TextEncoder/TextDecoder") { diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala index 6dd86b567..c49286877 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/vm/VMTest.scala @@ -32,14 +32,14 @@ class VMTest extends FunSpec { expectedSet foreach { case ExpectedData(animal, count, name) => script.runInContext(context) - assert(sandbox.animal == animal && sandbox.count == count && sandbox.name == name) + assert(sandbox.animal === animal && sandbox.count === count && sandbox.name === name) } } it("should compile and execute JavaScript code in a custom context") { val sandbox = new Sandbox(animal = "cat", count = 2, name = "kitty") VM.runInNewContext("""count += 1; name = "kitty"""", sandbox) - assert(sandbox.animal == "cat" && sandbox.count == 3 && sandbox.name == "kitty") + assert(sandbox.animal === "cat" && sandbox.count === 3 && sandbox.name === "kitty") } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala index 95baa64b6..ae0b2c0e1 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala @@ -21,7 +21,7 @@ class ZlibTest extends FunSpec { } { info(s"compressed => ${compressed.toString()}") info(s"uncompressed => ${uncompressed.toString()}") - assert(original.compare(uncompressed) == 0) + assert(original.compare(uncompressed) === 0) } } } From f42c2073bde9203ae3f11acc72e188869e8fdd5f Mon Sep 17 00:00:00 2001 From: exoego Date: Thu, 26 Sep 2019 08:34:39 +0900 Subject: [PATCH 3/3] Use assertion instead of info --- app/current/src/test/resources/fileA2.txt | 1 - .../scala/io/scalajs/nodejs/ProcessTest.scala | 46 ++++++----- .../io/scalajs/nodejs/StringDecoderTest.scala | 10 +-- .../io/scalajs/nodejs/TestEnvironment.scala | 2 + .../io/scalajs/nodejs/buffer/BufferTest.scala | 38 ++++----- .../child_process/ChildProcessAsyncTest.scala | 21 ----- .../child_process/ChildProcessTest.scala | 45 ++++++++--- .../scalajs/nodejs/cluster/ClusterTest.scala | 7 -- .../io/scalajs/nodejs/dns/DNSAsyncTest.scala | 50 ++++++++++-- .../scala/io/scalajs/nodejs/dns/DNSTest.scala | 42 ---------- .../nodejs/events/EventEmitterTest.scala | 53 +++++++----- .../scala/io/scalajs/nodejs/fs/FsTest.scala | 80 +++++++++++++------ .../nodejs/readline/ReadlineTest.scala | 37 ++++----- .../nodejs/url/URLSearchParamsTest.scala | 14 ++-- .../scala/io/scalajs/nodejs/url/URLTest.scala | 7 +- .../io/scalajs/nodejs/zlib/ZlibTest.scala | 5 -- 16 files changed, 236 insertions(+), 222 deletions(-) delete mode 100644 app/current/src/test/resources/fileA2.txt delete mode 100644 app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessAsyncTest.scala delete mode 100644 app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSTest.scala diff --git a/app/current/src/test/resources/fileA2.txt b/app/current/src/test/resources/fileA2.txt deleted file mode 100644 index 5e1c309da..000000000 --- a/app/current/src/test/resources/fileA2.txt +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/ProcessTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/ProcessTest.scala index 7c98f8561..3b12e316e 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/ProcessTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/ProcessTest.scala @@ -1,7 +1,7 @@ package io.scalajs.nodejs -import io.scalajs.JSON import io.scalajs.nodejs.Process.ProcessEnvExtensions +import io.scalajs.nodejs.os.OS import org.scalatest.FunSpec import scala.scalajs.js @@ -12,30 +12,34 @@ import scala.scalajs.js class ProcessTest extends FunSpec { describe("Process") { + val versionPrefix = + if (TestEnvironment.isExecutedInExactNode8) "v8." + else if (TestEnvironment.isExecutedInExactNode10) "v10." + else if (TestEnvironment.isExecutedInExactNode12) "v12." + else "Unknown node.js version" it("contains the following properties") { - show("process.arch", process.arch) - show("process.argv", process.argv) - show("process.config", process.config) - show("process.connected", process.connected) - show("process.cwd()", process.cwd()) - show("process.domain", process.domain) - show("process.env", process.env) - show("process.env.NODE_ENV", process.env.NODE_ENV) - show("process.env.PATH", process.env.PATH) - show("process.execArgv", process.execArgv) - show("process.execPath", process.execPath) - show("process.features", process.features) - show("process.moduleLoadList", process.moduleLoadList) - show("process.title", process.title) - show("process.version", process.version) - show("process.versions", JSON.stringify(process.versions)) - //show("process.stdout.isTTY", process.stdout.isTTY) - //show("process.stderr.isTTY", process.stderr.isTTY) + assert(process.arch.isInstanceOf[String]) + assert(process.argv.length === 1) + assert(process.argv(0).endsWith("node")) + assert(process.config("variables").asInstanceOf[js.Dictionary[String]]("host_arch") === OS.arch()) + assert(process.connected.isEmpty) + assert(process.cwd().nonEmpty) + assert(process.env("PATH").nonEmpty) + assert(process.env.PATH === process.env("PATH")) + assert(process.execArgv.length === 0) + assert(process.execPath.endsWith("node")) + assert(process.features.contains("debug")) + assert(process.moduleLoadList.length > 0) + assert(process.title.isInstanceOf[String]) + assert(process.version.startsWith(versionPrefix)) + assert(process.versions.node.map(v => s"v${v}").getOrElse("").startsWith(versionPrefix)) + + // TODO: actually undefined in test + // assert(process.stdout.isTTY) + // assert(process.stderr.isTTY) } } - private def show(label: String, value: js.Any) = info(s"$label: $value") - } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala index 002bdbf95..73025d9b6 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/StringDecoderTest.scala @@ -3,19 +3,15 @@ package io.scalajs.nodejs import io.scalajs.nodejs.buffer.Buffer import org.scalatest.FunSpec -/** - * StringDecoder Tests - */ class StringDecoderTest extends FunSpec { describe("StringDecoder") { it("should decode strings or buffer") { val decoder = new StringDecoder("utf8") - - info(decoder.write(Buffer.from("Hello "))) - info(decoder.write(Buffer.from("World"))) - info(decoder.end(Buffer.from("!"))) + assert(decoder.write(Buffer.from("Hello ")) === "Hello ") + assert(decoder.write(Buffer.from("World")) === "World") + assert(decoder.end(Buffer.from("!")) === "!") } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala index 55df5dd62..091cb88fe 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/TestEnvironment.scala @@ -8,6 +8,8 @@ object TestEnvironment { private lazy val nodeMajorVersion: Int = ChildProcess.execSync("node -v").asInstanceOf[Buffer].toString().drop(1).takeWhile(_.isDigit).toInt + def isWindows: Boolean = os.OS.platform().startsWith("win") + def isExecutedInExactNode12: Boolean = nodeMajorVersion == 12 def isExecutedInExactNode10: Boolean = nodeMajorVersion == 10 def isExecutedInExactNode8: Boolean = nodeMajorVersion == 8 diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala index 1e16daee7..14e16a648 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/buffer/BufferTest.scala @@ -1,15 +1,11 @@ package io.scalajs.nodejs.buffer -import io.scalajs.collection.Iterator.Entry import io.scalajs.nodejs.{TestEnvironment, buffer} import org.scalatest.FunSpec import scala.scalajs.js import scala.scalajs.js.typedarray.{ArrayBuffer, DataView, Uint8Array} -/** - * Buffer Tests - */ class BufferTest extends FunSpec { describe("Buffer") { @@ -26,19 +22,19 @@ class BufferTest extends FunSpec { assert(buf2.compare(buf3) === 1) } - it("should support iterating entries [classic]") { - val buf = Buffer.from("Hello!") - val it = buf.entries() - var result: Entry[js.Any] = null - do { - result = it.next() - if (!result.done) info(s"value: ${result.value}") - } while (!result.done) - } - - it("should support iterating entries [Scala]") { + it("should support iterating entries") { val buf = Buffer.from("Hello!") - for (value <- buf.entries()) info(s"value: $value") + val it = buf.entries() + assert( + it.toSeq.map(_.toSeq) === Seq( + Seq(0, 72), + Seq(1, 101), + Seq(2, 108), + Seq(3, 108), + Seq(4, 111), + Seq(5, 33) + ) + ) } it("should support buffer property") { @@ -76,24 +72,20 @@ class BufferTest extends FunSpec { it("should create buffers from strings") { val bufA = Buffer.from("Hello ") - info(s"bufA => ${bufA.toString()}") val bufB = Buffer.from("World") - info(s"bufB => ${bufB.toString()}") val bufC = bufA + bufB - info(s"bufC => ${bufC.toString()}, length = ${bufC.byteLength()}") assert(bufA.toString() === "Hello ") assert(bufB.toString() === "World") - assert(bufC.byteLength() === 11) + assert(bufC.byteLength === 11) } it("should create buffers from buffers") { val buffer = Buffer.from("hello") assert(Buffer.from(buffer).toString() === "hello") - // TODO: when Scala.js added TypedArray.from - // val uints = Uint8Array.from(???) - // assert(Buffer.from(uints).toString() ==="worlds") + val uints = Uint8Array.from(js.Array(72, 101, 108, 108, 111)) + assert(Buffer.from(uints).toString() === "Hello") } it("should support concat") { diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessAsyncTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessAsyncTest.scala deleted file mode 100644 index 33184f600..000000000 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessAsyncTest.scala +++ /dev/null @@ -1,21 +0,0 @@ -package io.scalajs.nodejs.child_process - -import io.scalajs.nodejs.buffer.Buffer -import org.scalatest.AsyncFunSpec - -import scala.concurrent.ExecutionContext - -class ChildProcessAsyncTest extends AsyncFunSpec { - override implicit val executionContext = ExecutionContext.Implicits.global - - describe("ChildProcess") { - it("supports execFuture(...)") { - for { - r <- ChildProcess.execFuture("cat ./package.json | wc -l") - } yield { - assert(r._1.asInstanceOf[Buffer].toString().trim.toInt > 0) - } - } - } - -} diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala index 0eee0f2b4..3008a3ddc 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/child_process/ChildProcessTest.scala @@ -1,11 +1,11 @@ package io.scalajs.nodejs package child_process -import io.scalajs.nodejs.Error import io.scalajs.nodejs.buffer.Buffer import io.scalajs.util.ScalaJsHelper._ -import org.scalatest.FunSpec +import org.scalatest.AsyncFunSpec +import scala.concurrent.{ExecutionContext, Promise} import scala.scalajs.js import scala.scalajs.js.| @@ -13,34 +13,57 @@ import scala.scalajs.js.| * ChildProcess Test * */ -class ChildProcessTest extends FunSpec { +class ChildProcessTest extends AsyncFunSpec { + override implicit val executionContext = ExecutionContext.Implicits.global + + describe("Extension") { + it("supports execFuture(...)") { + for { + r <- ChildProcess.execFuture("cat ./package.json | wc -l") + } yield { + assert(r._1.asInstanceOf[Buffer].toString().trim.toInt > 0) + } + } + } describe("ChildProcess") { it("supports exec(...)") { + val promise = Promise[(Output, Output)]() ChildProcess.exec( "cat ./package.json | wc -l", - callback = (error: Error, stdout: Buffer | String, stderr: Buffer | String) => { + callback = (error: Error, stdout: Output, stderr: Output) => { if (isDefined(error)) { - console.error(s"exec error: $error") + promise.failure(error) + } else { + promise.success((stdout, stderr)) } - info(s"stdout: $stdout") - info(s"stderr: $stderr") } ) + promise.future.map { + case (stdout, stderr) => + assert(stdout.toString.trim.toInt === 19) + assert(stderr.toString.trim === "") + } } it("supports execFile(...)") { + val promise = Promise[(Output, Output)]() ChildProcess.execFile( "ls", js.Array("-l"), - callback = (error: Error, stdout: Buffer | String, stderr: Buffer | String) => { + callback = (error: Error, stdout: Output, stderr: Output) => { if (isDefined(error)) { - console.error(s"exec error: $error") + promise.failure(error) + } else { + promise.success((stdout, stderr)) } - info(s"stdout: $stdout") - info(s"stderr: $stderr") } ) + promise.future.map { + case (stdout, stderr) => + assert(stdout.toString.trim.linesIterator.length > 10) + assert(stderr.toString.trim === "") + } } it("supports execSync(...)") { diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala index defe25cbc..a0aab4fcb 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/cluster/ClusterTest.scala @@ -8,30 +8,23 @@ import org.scalatest.FunSpec import scala.concurrent.duration._ import scala.scalajs.js -/** - * Cluster Tests - */ class ClusterTest extends FunSpec { describe("Cluster") { it("cluster should be master") { - info(s"cluster.isMaster => ${Cluster.isMaster}") assert(Cluster.isMaster) } it("cluster should not be a worker") { - info(s"cluster.isWorker => ${Cluster.isWorker}") assert(!Cluster.isWorker) } it("cluster.schedulingPolicy must be defined") { - info(s"cluster.schedulingPolicy => ${Cluster.schedulingPolicy}") assert(!js.isUndefined(Cluster.schedulingPolicy)) } it("cluster.settings must be defined") { - info(s"cluster.settings => ${JSON.stringify(Cluster.settings)}") assert(!js.isUndefined(Cluster.settings)) } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala index 0701af2bf..94705cd6e 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSAsyncTest.scala @@ -3,17 +3,57 @@ package dns import org.scalatest.AsyncFunSpec -import scala.concurrent.ExecutionContext +import scala.concurrent.{ExecutionContext, Promise} import scala.scalajs.js -/** - * DNS Tests - */ class DNSAsyncTest extends AsyncFunSpec { - private val domain = "google.com" override implicit val executionContext = ExecutionContext.Implicits.global + private val domain = "google.com" + describe("DNS") { + + it("supports lookup") { + val promise = Promise[String]() + DNS.lookup(domain, (err, ipAddress) => { + assert(err === null) + promise.success(ipAddress) + }) + promise.future.map { ipAddress => + assert(ipAddress.nonEmpty) + } + } + + it("supports lookupService:SSH") { + val promise = Promise[(String, String)]() + DNS.lookupService("127.0.0.1", 22, (err, hostname, service) => { + assert(err === null) + promise.success((hostname, service)) + }) + promise.future.map { + case (host, service) => + assert(host === "localhost") + assert(service === "ssh") + } + } + + it("supports resolve:NS") { + val promise = Promise[js.Array[String]]() + DNS.resolve( + domain, + "NS", + (err: DnsError, addresses: ResolveResult) => { + assert(err === null) + promise.success(addresses.asInstanceOf[js.Array[String]]) + } + ) + promise.future.map { addresses => + assert(addresses.nonEmpty) + } + } + } + + describe("DNS future extension") { it("supports lookupFuture") { DNS.lookupFuture(domain) map { case (ipAddress, ttl) => diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSTest.scala deleted file mode 100644 index 77a29b2c9..000000000 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/dns/DNSTest.scala +++ /dev/null @@ -1,42 +0,0 @@ -package io.scalajs.nodejs -package dns - -import org.scalatest.FunSpec - -import scala.scalajs.js - -/** - * DNS Tests - */ -class DNSTest extends FunSpec { - private val domain = "google.com" - - describe("DNS") { - - it("supports lookup") { - DNS.lookup(domain, (err, ipAddress) => { - assert(err === null) - info(s"lookup - ipAddress: $ipAddress") - }) - } - - it("supports lookupService:SSH") { - DNS.lookupService("127.0.0.1", 22, (err, hostname, service) => { - assert(err === null) - assert(hostname.nonEmpty) - assert(service.nonEmpty) - }) - } - - it("supports resolve:NS") { - DNS.resolve( - domain, - "NS", - (err: DnsError, addresses: ResolveResult) => { - assert(err === null) - assert(addresses.asInstanceOf[js.Array[String]].nonEmpty) - } - ) - } - } -} diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala index 0111f8caf..63137ceb6 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/events/EventEmitterTest.scala @@ -1,49 +1,62 @@ package io.scalajs.nodejs.events -import io.scalajs.JSON -import org.scalatest.FunSpec +import org.scalatest.AsyncFunSpec +import scala.concurrent.{ExecutionContext, Promise} import scala.scalajs.js -/** - * EventEmitter Tests - */ -class EventEmitterTest extends FunSpec { +class EventEmitterTest extends AsyncFunSpec { + override implicit val executionContext = ExecutionContext.Implicits.global describe("EventEmitter") { - it("should handle events with arguments") { + it("should handle custom events with arguments") { + val promise = Promise[js.Array[Int]]() val myEmitter = new EventEmitter() - myEmitter.on("event", (args: js.Array[Int]) => { - info(s"a custom event was fired with args: ${JSON.stringify(args)}") + myEmitter.on("custom-event", (args: js.Array[Int]) => { + promise.success(args) }) - myEmitter.emit("event", js.Array(1, 2, 3)) + myEmitter.emit("custom-event", js.Array(1, 2, 3)) + + promise.future.map { array => + assert(array.mkString(",") === "1,2,3") + } } it("should handle one-time events") { + val promise = Promise[Unit]() val myEmitter = new EventEmitter() var n = 0 myEmitter.once("event", () => { n += 1 - info(s"n = $n") + promise.success(()) }) myEmitter.emit("event") - // Prints: 1 myEmitter.emit("event") - // Ignored + + promise.future.map { _ => + assert(n === 1) + } } it("should handle repeated events") { + val promise = Promise[Unit]() val myEmitter = new EventEmitter() var n = 0 - myEmitter.on("event", () => { - n += 1 - info(s"n = $n") - }) + myEmitter + .on("event", () => { + n += 1 + }) + .on("end", () => { + promise.success(()) + }) myEmitter.emit("event") - // Prints: 1 myEmitter.emit("event") - // Prints: 2 + myEmitter.emit("end") + + promise.future.map { _ => + assert(n === 2) + } } it("should count the number of fired events") { @@ -52,7 +65,5 @@ class EventEmitterTest extends FunSpec { myEmitter.on("event", () => {}) assert(myEmitter.listenerCount("event") === 2) } - } - } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala index 5e6e82101..3df110f67 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala @@ -1,60 +1,80 @@ package io.scalajs.nodejs.fs -import io.scalajs.JSON import io.scalajs.nodejs.setImmediate -import io.scalajs.nodejs.util.Util import io.scalajs.util.ScalaJsHelper._ -import org.scalatest.FunSpec +import org.scalatest.AsyncFunSpec + +import scala.concurrent.{ExecutionContext, Promise} /** * File System (Fs) Tests * */ -class FsTest extends FunSpec { +class FsTest extends AsyncFunSpec { + override implicit val executionContext = ExecutionContext.Implicits.global final val testResources = "./app/current/src/test/resources/" describe("Fs") { it("supports watching files") { + val promise = Promise[(String, String)]() val watcher = Fs.watch(s"${testResources}", (eventType, file) => { - info(s"watcher: eventType = '$eventType' file = '$file'") + if (!promise.isCompleted) { + promise.success((eventType, file)) + } }) - info(s"watcher: ${Util.inspect(watcher)}") + assert(watcher !== null) setImmediate( () => Fs.writeFile(s"${testResources}1.txt", "Hello", error => { if (isDefined(error)) { - alert(s"error: ${JSON.stringify(error)}") + promise.failure(error) } }) ) + + promise.future.map { + case (eventType, file) => + assert(eventType === "change") + assert(file === "1.txt") + } } it("should stream data") { + val promise1 = Promise[(Stats, Stats)]() + val promise2 = Promise[Stats]() + val promise3 = Promise[Boolean]() + val file1 = s"${testResources}fileA1.txt" val file2 = s"${testResources}fileA2.txt" val file3 = s"${testResources}fileC2.txt" - val readable = Fs.createReadStream(file1) + val readable = Fs.createReadStream(file1, new FileInputOptions(encoding = "utf8")) val writable = Fs.createWriteStream(file2) - readable.setEncoding("utf8") - readable.onData[String](chunk => writable.write(chunk)) + readable.onData[String](chunk => { + writable.end(chunk) + }) + Fs.writeFileSync(file1, "Hello World") + writable.onFinish { () => - info("Comparing file sizes:") - info(s"$file1 is ${Fs.statSync(file1).size} bytes") - info(s"$file2 is ${Fs.statSync(file2).size} bytes") - assert(Fs.statSync(file1).size === Fs.statSync(file2).size) + promise1.success((Fs.statSync(file1), Fs.statSync(file2))) - info("should rename the file") Fs.renameSync(file2, file3) - assert(Fs.statSync(file2).isFile()) + promise2.success(Fs.statSync(file3)) - info("should delete the file") Fs.unlinkSync(file3) - val deleted = !Fs.existsSync(file3) - info(s"deleted? $deleted") + promise3.success(!Fs.existsSync(file3)) + } + + for { + (stat1, stat2) <- promise1.future + stat3 <- promise2.future + deleted <- promise3.future + } yield { + assert(stat1.size === stat2.size) + assert(stat3.isFile()) assert(deleted) } } @@ -66,18 +86,30 @@ class FsTest extends FunSpec { val readable = Fs.createReadStream(file1) val writable = Fs.createWriteStream(file2) readable.pipe(writable) + + val promise = Promise[(Stats, Stats)]() writable.onFinish { () => - info("Comparing file sizes:") - info(s"$file1 is ${Fs.statSync(file1).size} bytes") - info(s"$file2 is ${Fs.statSync(file2).size} bytes") - assert(Fs.statSync(file1).size === Fs.statSync(file2).size) + promise.success((Fs.statSync(file1), Fs.statSync(file2))) + } + + promise.future.map { + case (stat1, stat2) => + assert(stat1.size === stat2.size) } } it("support access") { + val promise = Promise[Unit]() Fs.access("./package.json", err => { - assert(err === null) + if (isDefined(err)) { + promise.failure(err) + } else { + promise.success(()) + } }) + promise.future.map { _ => + succeed + } } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala index 18de282b9..0a9134b4a 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/readline/ReadlineTest.scala @@ -1,19 +1,23 @@ package io.scalajs.nodejs.readline import io.scalajs.nodejs.fs.Fs -import io.scalajs.nodejs.{console, process} -import org.scalatest.FunSpec +import io.scalajs.nodejs.process +import org.scalatest.AsyncFunSpec + +import scala.concurrent.{ExecutionContext, Promise} /** * Readline Tests */ -class ReadlineTest extends FunSpec { +class ReadlineTest extends AsyncFunSpec { + override implicit val executionContext = ExecutionContext.Implicits.global describe("Readline") { it("should read/stream files from disk") { - var lineNo = 0 - val file = "./package.json" + val promise = Promise[Unit]() + var lineNo = 0 + val file = "./package.json" val reader = Readline.createInterface( new ReadlineOptions( input = Fs.createReadStream(file), @@ -24,32 +28,25 @@ class ReadlineTest extends FunSpec { reader.onLine { line => lineNo += 1 - info(f"[$lineNo%02d] $line") } reader.onClose { () => - info("# stream closed.") + promise.success(()) } + promise.future.map(_ => assert(lineNo === 19)) } it("has REPL-like functionality") { - val rl = Readline.createInterface(new ReadlineOptions(input = process.stdin, output = process.stdout)) + val promise = Promise[Unit]() + val rl = Readline.createInterface(new ReadlineOptions(input = process.stdin, output = process.stdout)) rl.setPrompt("OHAI> ") rl.prompt() - rl.onLine { line => - line.trim() match { - case "hello" => - console.log("world!") - case _ => - console.log(s"Say what? I might have heard `${line.trim()}`") - } - rl.prompt() - - } onClose { () => - console.log("Have a great day!") - //process.exit(0) + rl.onClose { () => + promise.success(()) } + rl.close() + promise.future.map(_ => succeed) } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala index feae80468..9614d2d6d 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLSearchParamsTest.scala @@ -1,23 +1,16 @@ package io.scalajs.nodejs.url -import io.scalajs.nodejs.console import org.scalatest.FunSpec import scala.scalajs.js -/** - * URLSearchParams Tests - */ class URLSearchParamsTest extends FunSpec { describe("URLSearchParams") { it("should parse the string as a query string") { val params = new URLSearchParams("user=abc&query=xyz") - info(params.get("user")) // Prints "abc" assert(params.get("user") === "abc") - - info(params.toString) // Prints "user=abc&query=xyz" assert(params.toString === "user=abc&query=xyz") } @@ -28,15 +21,18 @@ class URLSearchParamsTest extends FunSpec { "query" -> js.Array("first", "second") ) ) - info(params.getAll("query").mkString(", ")) // Prints [ "first,second" ] assert(params.getAll("query").toSeq === Seq("first,second")) } it("should iterates over each name-value pair in the query and invokes the given function") { val myURL = new URL("https://example.org/?a=b&c=d") + val array = js.Array[String]() myURL.searchParams.forEach((value, name, searchParams) => { - console.log(name, value, myURL.searchParams === searchParams) + array.push(s"${name}=${value}") + assert(myURL.searchParams === searchParams) }) + assert(array(0) === "a=b") + assert(array(1) === "c=d") } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLTest.scala index 8e7cf0c29..58b643753 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/url/URLTest.scala @@ -3,19 +3,16 @@ package url import org.scalatest._ -/** - * URL Tests - */ class URLTest extends FunSpec { describe("URL") { it("Gets and sets the serialized query portion of the URL") { val myURL = new URL("https://example.org/abc?123") - info(myURL.search) // Prints ?123 + assert(myURL.search === "?123") myURL.search = "abc=xyz" - info(myURL.href) + assert(myURL.href === "https://example.org/abc?abc=xyz") } } diff --git a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala index ae0b2c0e1..b9fc8c4d3 100644 --- a/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala +++ b/app/nodejs-v8/src/test/scala/io/scalajs/nodejs/zlib/ZlibTest.scala @@ -5,9 +5,6 @@ import org.scalatest.FunSpec import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue -/** - * Zlib Tests - */ class ZlibTest extends FunSpec { describe("Zlib") { @@ -19,8 +16,6 @@ class ZlibTest extends FunSpec { compressed <- Zlib.deflateFuture(original) uncompressed <- Zlib.unzipFuture(compressed, new CompressionOptions(finishFlush = Zlib.Z_SYNC_FLUSH)) } { - info(s"compressed => ${compressed.toString()}") - info(s"uncompressed => ${uncompressed.toString()}") assert(original.compare(uncompressed) === 0) } }