File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
javalanglib/src/main/scala/java/lang
test-suite/src/test/scala/org/scalajs/testsuite/javalib Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,16 @@ package java.lang
6
6
* So we use a binary signature that no Java source file can ever produce.
7
7
*/
8
8
class Thread private (dummy : Unit ) extends Runnable {
9
+ private [this ] var name : String = " main" // default name of the main thread
10
+
9
11
def run (): Unit = ()
10
12
13
+ final def setName (name : String ): Unit =
14
+ this .name = name
15
+
16
+ final def getName (): String =
17
+ this .name
18
+
11
19
def getStackTrace (): Array [StackTraceElement ] =
12
20
scala.scalajs.runtime.StackTrace .getCurrentStackTrace()
13
21
}
Original file line number Diff line number Diff line change @@ -14,6 +14,18 @@ import org.scalajs.jasminetest.JasmineTest
14
14
object ThreadTest extends JasmineTest {
15
15
16
16
describe(" java.lang.Thread" ) {
17
+ it(" getName and setName" ) {
18
+ val t = Thread .currentThread()
19
+ expect(t.getName).toBe(" main" ) // default name of the main thread
20
+ t.setName(" foo" )
21
+ try {
22
+ expect(t.getName).toBe(" foo" )
23
+ } finally {
24
+ t.setName(" main" ) // don't pollute the rest of the world with this test
25
+ }
26
+ expect(t.getName).toBe(" main" )
27
+ }
28
+
17
29
it(" Thread.currentThread().getStackTrace() should exist and not crash" ) {
18
30
java.lang.Thread .currentThread().getStackTrace()
19
31
}
You can’t perform that action at this time.
0 commit comments