AccessException -< IllegalAccessException; added TODO() and NotImplementedException
This commit is contained in:
1 parent
e0a59c8db6
commit
514ad96148
9 files changed
+107
-42
No files matched your search
@@ -488,7 +488,7 @@ class OOTest {
|
||||
fun setValue(newValue) { y = newValue }
|
||||
}
|
||||
assertEquals(100, A().y)
|
||||
assertThrows(AccessException) { A().y = 200 }
|
||||
assertThrows(IllegalAccessException) { A().y = 200 }
|
||||
val a = A()
|
||||
a.setValue(200)
|
||||
assertEquals(200, a.y)
|
||||
@@ -502,7 +502,7 @@ class OOTest {
|
||||
}
|
||||
val c = C(10)
|
||||
assertEquals(10, c.y)
|
||||
assertThrows(AccessException) { c.y = 20 }
|
||||
assertThrows(IllegalAccessException) { c.y = 20 }
|
||||
c.setBValue(30)
|
||||
assertEquals(30, c.y)
|
||||
|
||||
@@ -515,7 +515,7 @@ class OOTest {
|
||||
}
|
||||
val d = D()
|
||||
assertEquals(0, d.y)
|
||||
assertThrows(AccessException) { d.y = 10 }
|
||||
assertThrows(IllegalAccessException) { d.y = 10 }
|
||||
d.setY(20)
|
||||
assertEquals(20, d.y)
|
||||
"""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2025 Sergey S. Chernov real.sergeych@gmail.com
|
||||
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -4532,4 +4532,32 @@ class ScriptTest {
|
||||
""".trimIndent())
|
||||
}
|
||||
|
||||
// @Test
|
||||
// fun testUserClassExceptions() = runTest {
|
||||
// eval("""
|
||||
// val x = try { throw IllegalAccessException("test1") } catch { it }
|
||||
// assertEquals("test1", x.message)
|
||||
// assert( x is IllegalAccessException)
|
||||
// assertThrows(IllegalAccessException) { throw IllegalAccessException("test2") }
|
||||
//
|
||||
// class X : Exception("test3")
|
||||
// val y = try { throw X() } catch { it }
|
||||
// println(y)
|
||||
// assertEquals("test3", y.message)
|
||||
// assert( y is X)
|
||||
//
|
||||
// """.trimIndent())
|
||||
// }
|
||||
|
||||
@Test
|
||||
fun testTodo() = runTest {
|
||||
eval("""
|
||||
assertThrows(NotImplementedException) {
|
||||
TODO()
|
||||
}
|
||||
val x = try { TODO("check me") } catch { it }
|
||||
assertEquals("check me", x.message)
|
||||
""".trimIndent())
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user