Commit Graph

66 Commits

Author SHA1 Message Date
Abduqodiri Qurbonzoda 421cb6971d Optimized toArray method for ArrayDeque and ListBuilder #KT-42720 2021-03-06 11:14:50 +03:00
Ilya Gorbunov ca6ce151a2 Unify test package names in kotlin-stdlib tests
This makes 'test.' an implicit package prefix, thus fixing the inspection
"Package directive doesn't match file location" positive in almost all
test files.
2021-02-25 09:58:14 +03:00
Dmitriy Novozhilov bc3b791cd8 [TMP] Remove :kotlin-coroutines-experimental-compat module 2021-01-28 13:19:34 +03:00
Ilya Gorbunov 79e426270c Rename Random.Default serialization surrogate object (KT-25571) 2020-12-31 06:57:17 +03:00
Iaroslav Postovalov 00506a75d3 Make Random implementations serializable (KT-25571)
Make Random.Default, XorWowRandom, and wrapper classes for JDK Random implement Serializable interface.

Co-authored-by: Ilya Gorbunov <ilya.gorbunov@jetbrains.com>
2020-12-31 04:10:28 +03:00
Abduqodiri Qurbonzoda 1314adb6f7 Locale-agnostic case conversions by default #KT-43023 2020-12-30 10:08:25 +03:00
Ilya Gorbunov 66f5c98505 Deprecate createTempFile/createTempDir functions
Document their potential permission problems.
Suppress this deprecation in tests.
2020-11-10 18:25:48 +03:00
Valeriy.Vyrva 30ff886754 Improve docs for createTempDir/createTempFile
#KT-35218
2020-08-10 17:29:25 +03:00
Ilya Gorbunov 2f3e1dcbc6 Add EXACTLY_ONCE contract to suspendCoroutine* functions
Update line numbers in the affected test.
2020-07-10 01:05:16 +03:00
Ilya Gorbunov 33150a0809 KT-38817 capitalize uses title case for the first char where available
This unifies its behavior with new capitalize overload with Locale.

Co-authored-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2020-06-24 16:45:09 +03:00
Ilya Gorbunov e13a38a758 Fix OnlyInputType usage in tests where it can be invisible 2020-06-18 09:34:13 +03:00
Alexander Udalov 650469024e Fix expected FQ name in JavaTypeTest.nestedTypes 2020-06-17 19:47:45 +02:00
Ilya Gorbunov 41131e46d7 Shadow addSuppressed member with an extension
#KT-38777
2020-06-17 19:45:15 +03:00
Alexander Udalov 9e37b62f62 Support KType.javaType in stdlib
#KT-32241 Fixed
2020-06-17 18:33:08 +02:00
Valeriy.Vyrva c023a02884 Create SortedMap with Comparator and items
KT-34142
2020-06-04 02:04:22 +03:00
Ilya Gorbunov 6a24becd1d Introduce sumOf with various selector types
#KT-11253
2020-06-02 19:01:43 +03:00
Abduqodiri Qurbonzoda d6472aa700 Reverse range and sortDescending range #KT-36955 2020-04-20 22:06:28 +03:00
Ilya Gorbunov 408b441a71 Rename extension toStringWithTrace to stackTraceToString
#KT-37603
2020-04-13 09:32:42 +03:00
Ilya Gorbunov 552bcdb31b Introduce Throwable.toStringWithTrace
#KT-37603
2020-04-13 09:32:41 +03:00
Ilya Gorbunov 7b7263c5bf Implement common Throwable.addSuppressed/suppressed extensions
Instead of `suppressed` Array we provide `suppressedExceptions` List

#KT-23737
2020-04-13 09:32:41 +03:00
Ilya Gorbunov fc9ac67980 Tune parameters of time-sensitive tests
Lessen CPU load on the main thread.
Remove fragile checks.
2020-04-10 01:38:46 +03:00
Ilya Gorbunov d88d2cb058 Test new Double/Float constants
Split test expectations based on actual support of enforced Float range

KT-29182, KT-13887
2020-04-02 04:04:04 +03:00
Roman Elizarov e26a3ad033 Speed up stdlib readLine function (#3185)
There are several performance optimizations:

* ByteBuffer/CharBuffer/StringBuilder objects pre-allocated and are
  reused on each call to readLine.
* The state for readLine is lazily allocated via JVM classloading
  (using a singleton object).
* There is an auto-detection heuristic for "directEOL" encodings which
  represent LF ('\n') directly as the corresponding byte
  (UTF-8 and many single-byte encodings are like that).
  When "directEOL" encoding is used, then bytes are batched into
  ByteBuffer for a single call to CharsetDecoder.decode which
  results in higher throughput. Otherwise (UTF-16, etc), slower
  byte-by-byte approach is used.
* Bytes and chars are directly moved in/out of byte/char arrays and
  ByteBuffer/CharBuffer wrappers are used only to interface with
  JVM CharsetDecoder class (which is the slowest piece).
* StringBuilder is not used at all for short lines (<=32 chars).

There are also some function improvements to readLine functionality:

* Restriction on "max chars per byte" is lifted, so readLine works with
  all encodings that JVM supports.
* It support on-the-fly changes to system default charset, because
  it rechecks current charset on each call and updates it decoder
  when needed.

All the other features of readLine function are retained:

* It does not read more bytes from System.in than needed, so it
  is compatible with other ways to read System.in. On-the-fly
  changes to System.in are supported.
* It is thread-safe. Its internal mutable state is protected by
  synchronization.
* There is an internal method for tests that supports explicit
  charset specification, but the name of this method has changed.

There are additional tests:

* Check all supported encodings on JVM to make sure that readLine
  works correctly with them all.
* Check unicode code points of different bits length with all standard
  unicode encodings (UTF-8, UTF-16, and UTF-32 in LE/HE byte orders).

Benchmarks that compare different implementations of readLine,
including this one (readLine6NoLV in the set) can be found here:
https://github.com/elizarov/ReadLineBenchmark

Taking BufferedReader as 100% baseline we see that:

* Current readLine is 7.5 times slower than BufferedReader baseline.
* New implementation in this commit is 2.5 timer slower than baseline.
  It is ~3 times faster than existing implementation of readLine.

Altogether these optimizations are enough to enable reading of
~500K lines in sports programming setting under 2s time-limit with
plenty of headroom in time. Example that is using this version of
readLine can be found here:
https://codeforces.com/contest/1322/submission/73005366

#KT-37416 Fixed
2020-03-23 14:36:55 +03:00
Abduqodiri Qurbonzoda e632d58936 Nullable Array.contentEquals/contentHashCode/contentToString #KT-34161 2020-03-12 18:01:23 +03:00
Abduqodiri Qurbonzoda d5c851980c String.toBoolean() should be String?.toBoolean() #KT-14119 2020-03-05 17:53:29 +03:00
Abduqodiri Qurbonzoda fc22cfa896 String.format does not support no locale #KT-22932 2020-03-05 16:38:43 +03:00
Ilya Gorbunov b5a0daabc3 Extract kotlin.coroutines.experimental API into compat artifact
Add public API dump for kotlin-coroutines-experimental-compat

#KT-36083
2020-01-29 09:12:39 +03:00
Ilya Gorbunov 8f37ace9ee Finally drop deprecated mod functions from numeric types
#KT-26654
2020-01-23 19:28:22 +03:00
Ilya Gorbunov a98f36bce4 Reorganize existing Closeable/AutoCloseable.use tests 2019-12-28 03:02:01 +03:00
Toshiaki Kameyama 941de655c4 Add contract for 'use'
#KT-35216 Fixed
2019-12-28 02:54:29 +03:00
Abduqodiri Qurbonzoda 20d02dd0ee Commonize StringBuilder 2019-12-04 22:15:33 +03:00
Ilya Gorbunov 885d99068c Test reading files with incorrectly reported length
#KT-33864
2019-09-28 19:23:26 +03:00
Jake Wharton 1a6069382e Provide Array.fill in common stdlib
KT-32359
2019-08-01 19:02:38 +03:00
Ilya Gorbunov 804d2b2d8c Helper utilities to execute test code on particular platforms 2019-06-18 03:59:52 +03:00
Ilya Gorbunov 8badfca459 Fix titlecase lowering in decapitalize
Replace isUpperCase() with !isLowerCase check to lower both
upper- and titlecased first chars.
2019-05-29 03:54:46 +03:00
Ilya Gorbunov a921bd04e0 capitalize/decapitalize: improve docs, add one test 2019-05-29 03:54:46 +03:00
Jake Wharton af31794f60 Add Locale-accepting overloads for (de)capitalize in JDK stdlib
#KT-28933 fixed
2019-05-29 03:35:33 +03:00
Abduqodiri Qurbonzoda c8a4fa58cd Implement String to/from ByteArray conversion (KT-24810) 2019-05-06 15:54:28 +03:00
nikita.movshin 65244b4bea Update copyright.
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
Update only 2 lines copyright.
2019-04-23 20:09:22 +03:00
Ilya Gorbunov 91c7233ed8 Make Throwable.addSuppressed extension work without kotlin-stdlib-jdk7*
*given that it runs on JDK7 and higher. The addSuppressed member
is called with reflection when it's available.
kotlin-stdlib-jdk7 extension still overrides that and calls
addSuppressed member statically as before.

#KT-30560 Fixed
2019-03-28 22:42:20 +03:00
Abduqodiri Qurbonzoda 876dff6d22 Implement fill extension function for UArrays (KT-28339) 2019-03-08 23:34:33 +03:00
Abduqodiri Qurbonzoda 550c74bb6b Implement binarySearch method for UArrays (KT-27262) 2019-03-08 23:34:33 +03:00
Ilya Gorbunov f50820045a Allow setting seed only once, as it is set from superclass constructor
Add tests for Java<->Kotlin Random wrappers.

#KT-29520 Fixed
2019-02-13 00:21:22 +03:00
Ilya Gorbunov 7b08f6f8f1 readLine: extend buffer to decode surrogate pairs from utf-8 correctly
CharBuffer had capacity to hold 2 chars, which was not enough to append
a surrogate pair when the buffer was not empty.

The buffer was extended and the decoding algorithm rewritten to deal with
a buffer of any length.

#KT-28572 Fixed
2018-12-07 17:42:09 +03:00
Ilya Gorbunov a534bfc32f Move index overflow tests to another test source set
To avoid reporting them as ignored and to make it more easy to run them
when needed.
2018-11-30 07:27:07 +03:00
Ilya Gorbunov 673844a059 Move coroutine tests to other stdlib-jvm tests 2018-11-28 06:05:02 +03:00
Ilya Gorbunov 8d0d6d1bf3 Do not mutate Matcher in MatchResult.next()
Instead of mutating the matcher create a new one when `next()` is called.
This allows getting named groups from that matcher later.

Add lookbehind in matchSequence test to ensure this change doesn't alter
the existing behavior.

Also fixes #KT-20865
2018-11-16 20:29:38 +03:00
Alexander Udalov 55c8b35eee Remove unneeded default imports in stdlib and tests 2018-10-01 13:39:02 +02:00
Ilya Gorbunov 6786b9ece2 Stdlib tests: cleanup warnings 2018-09-14 15:32:08 +03:00
Mikhail Zarechenskiy 3431123cab Fixes for tests about mod
#KT-25217
2018-09-10 06:31:55 +03:00