thana
11/22/2019, 12:53 PM@Test
fun testFoo() {
val a: Long = 6
val b: Long? = createFoo()
assertEquals(a, b)
}
fun createFoo(): Long? = if (true) 5 else null
fails with jsNodeTest - that makes it impossible to make use of the new features đthana
11/22/2019, 12:54 PMIlya Goncharov [JB]
11/22/2019, 1:07 PM6 != 5 or do you have build fails? I canât reproduce itthana
11/22/2019, 1:08 PMthana
11/22/2019, 1:09 PMthana
11/22/2019, 1:10 PMLong? and i check for a conrete Longthana
11/22/2019, 1:11 PMthana
11/22/2019, 1:15 PMdebug=true and remote debug the test with chromethana
11/22/2019, 1:18 PMKotlin.Long {low_: -1824411265, high_: 366} and expected is Kotlin.Long {low_: -1824411265, high_: 366} yes assertEquals failsIlya Goncharov [JB]
11/22/2019, 1:22 PM--inspect-brk on mocha and actually you can âdebugâ mocha instead of test script. Do you set debug property and it debugs test script?thana
11/22/2019, 1:27 PMthana
11/22/2019, 1:28 PMIlya Goncharov [JB]
11/22/2019, 1:35 PMif you set a breakpoint in the testcode its easy to debug itWow! Thatâs good đ
so but still assertEquals fails with to identical long objects... now what can i do? đOn my project, test is passed, could you please share your project?
@Test
fun testFoo() {
val a: Long = 6
val b: Long? = createFoo()
assertEquals(a, b)
}
fun createFoo(): Long? = if (true) 6 else nullthana
11/22/2019, 1:36 PMthana
11/22/2019, 1:55 PMconsole.log(other) prints Kotlin.Long other instanceof Long prints falsethana
11/22/2019, 1:56 PMthis.equals(other) failsthana
11/22/2019, 3:12 PMinstanceof would fail? what does instanceof? i mean i can SEE IN THE DEBUGGER it's a Kotlin.Long - still the check faiilsthana
11/22/2019, 3:13 PMequalsLong(other) evaluates to true. it's only the instanceof check that failsbashor
11/22/2019, 3:35 PMother instanceof Long false iff otherâs prototype isnât Long , you could get such object after serialaze and deserialaze, for examplethana
11/22/2019, 3:41 PMthana
11/22/2019, 3:41 PMbashor
11/22/2019, 3:44 PM__proto__ properti of objectbashor
11/22/2019, 3:45 PMObject.getPrototypeOf(expr)bashor
11/22/2019, 3:45 PMthana
11/22/2019, 4:40 PMbashor
11/22/2019, 5:03 PMother.__proto__ ?thana
11/25/2019, 8:03 AMbashor
11/25/2019, 10:24 AMother.__proto__ === Long return true?bashor
11/25/2019, 10:26 AMa.__proto__ === Long and a instanceof Long must be same for the same Long .thana
11/25/2019, 3:05 PMother.__proto__ === Long nor this.__proto__ === Long evaluates to truethana
11/25/2019, 3:06 PMKotlin.Long or else i'd get an error that Long cannot be foundthana
11/25/2019, 3:11 PMthis instanceof Kotlin.Long is true)thana
11/25/2019, 4:03 PMcom.soywiz.klock.DateTime.nowUnixLong() while this IS instanceof Long the actual value returned walks through a code passage where Kotlin.Long is not declared and a soon as it reaches the test code where Kotlin.Long is declared again, value instanceof Kotlin.Long evaluates to falsethana
11/25/2019, 4:30 PMassertTrue(com.soywiz.klock.DateTime.nowUnixLong() is Long) seems to always fail when run with mochathana
11/25/2019, 4:31 PMthana
11/25/2019, 4:53 PMDateTime_0.Companion.nowUnixLong() instanceof Kotlin.Long -> false
the method is declared as
DateTime$Companion.prototype.nowUnixLong = function () {
return Kotlin.Long.fromNumber(KlockInternal_getInstance().currentTime);
};
otlin.Long.fromNumber(KlockInternal_getInstance().currentTime) instanceof Kotlin.Long -> truethana
11/25/2019, 4:53 PMbashor
11/25/2019, 8:45 PMbashor
11/25/2019, 8:46 PMthana
11/26/2019, 7:12 AMimport kotlin.test.Test
import kotlin.test.assertTrue
class Foo {
@Test
fun foo() {
assertTrue(com.soywiz.klock.DateTime.nowUnixLong() is Long)
}
}thana
11/26/2019, 7:12 AMthana
11/26/2019, 7:13 AMKotlin.Long is constructedthana
11/26/2019, 7:44 AMthana
11/26/2019, 7:45 AMthana
11/26/2019, 8:42 AMthana
11/26/2019, 8:42 AMbashor
11/26/2019, 9:23 AMbashor
11/26/2019, 9:23 AMbashor
11/26/2019, 9:25 AMthana
11/26/2019, 9:26 AMIlya Goncharov [JB]
11/26/2019, 9:42 AMIlya Goncharov [JB]
11/26/2019, 9:44 AMpackage.json in its artifact with block dependencies with written kotlin 1.3.50Ilya Goncharov [JB]
11/26/2019, 9:44 AMIlya Goncharov [JB]
11/26/2019, 9:54 AMbuild.gradle.kts, it deletes node_modules for klock after Npm install
It remove the second Kotlin runtime for only klock, and it will uses common runtime
But it is hacky (and only temporary solution), better to report about problem to klock maintainers
tasks.getByName("kotlinNpmInstall") {
doLast {
File("$buildDir/js/node_modules/klock-root-klock/node_modules").deleteRecursively()
}
}thana
11/26/2019, 12:21 PMpackage.json i would end up with the dependency on kotlin.js twice and get the very same error, wouldn't i?thana
11/26/2019, 12:27 PMthana
11/26/2019, 12:27 PMIlya Goncharov [JB]
11/26/2019, 12:49 PMpackage.json i would end up with the dependency on kotlin.js twice and get the very same error, wouldnât i?
The main problem, that gradle donât look at package.json , we install npm dependencies via Yarn. When we unzip gradle dependency with klock, it unzipped with bundled package.json and them npm dependencies. For gradle they have no kotlin dependency, but in fact for JavaScript world there is. And thatâs why we have no any compilation or build problem and get error only in runtime. Because the problem is that in runtime we have 2 kotlinâs versions.thana
11/26/2019, 1:38 PMthana
11/26/2019, 1:39 PMDeactivated User
12/01/2019, 3:17 PMpackage.json file recommended at all? I included because some people wanted to use it with npm: https://github.com/korlibs/klock/issues/54 but might not be a good idea, or something generated by the kotlin gradle plugin? Not sure. I could add the delete stuff but looks a bit hacky. Any suggestions here?Ilya Goncharov [JB]
12/02/2019, 8:02 AMDeactivated User
12/02/2019, 10:22 AMthana
12/02/2019, 11:03 AMDeactivated User
12/02/2019, 11:04 AMthana
12/02/2019, 11:04 AM