Commit Graph

1124 Commits

Author SHA1 Message Date
Ilya Gorbunov 1014434475 KT-58046 Use saturated math in LongTimeMark implementation
- keep offset in range (-1..+1) of time source units
- when adding big or infinite offset, saturate startedAt instead
- displace initial reading to zero, similar to MonotonicTimeSource
- fix the zero reading in TestTimeSource by calling markNow in constructor
- use more precise reading adjustment in TestTimeSource for big durations
- add a note about comparable time marks for AbstractLongTimeSource and TestTimeSource
2023-04-18 15:25:31 +00:00
Ilya Gorbunov 17d977977c KT-58058 Duration truncation internal helper function 2023-04-18 15:25:30 +00:00
Filipp Zhinkin 368f21461c KT-55091 Optimize Sequence::toSet/toList implementation
Sequence::toSet and Sequence::toList both create a
collection, fill it with elements, and then try to optimize a result
by returning empty, singleton, or the allocated collection depending on
the elements count.
Instead of allocating the collection and then trying to return
an optimized instance it is worth checking the sequence's size
beforehand and return empty/singleton collection when possible.

Proposed change optimize performance of aforementioned functions and
also reduce allocation rate when a sequence consists of 0 or 1 elements.

^KT-55091 fixed
2023-04-17 08:58:20 +00:00
Iaroslav Postovalov fb80c0cb0d Override toString function in stdlib delegates
Co-authored-by: ilya-g <ilya.gorbunov@jetbrains.com>
2023-04-11 14:46:29 +00:00
Abduqodiri Qurbonzoda c961c15729 Commonize AssertionError(message, cause) constructor 2023-04-11 13:32:54 +00:00
Filipp Zhinkin d0847f2519 KT-57617 Delegate iterators of reversed list views to underlying list iterators
Improve the performance of reversed list view iterators by delegating to
underlying list iterators instead of using implementations provided by
the AbstractList.
Latter use AbstractList::get(index: Int) to implement next() and
previous() methods and depending on the underlying list's implementation
it may lead to worse performance.

The change also improves reversed list views test coverage.
2023-04-11 08:16:21 +00:00
Ilya Gorbunov 2dbff89098 Split tests for MutableList.shuffle and Iterable.shuffled 2023-04-08 14:47:30 +00:00
Ilya Gorbunov f13e127b0f KT-57607 Add test for MutableList.addAll at index
Also improve other operations test coverage
2023-04-08 14:47:30 +00:00
Igor Yakovlev 5a46cb1c40 [Wasm] Fix invalid float and double sign parser for '-Infinity' value 2023-04-04 18:39:18 +00:00
Ilya Chernikov 1d72681e4e K2: Fix stdlib test use of assertEquals
fixes test compilation according to the workaround
described in #KT-56717
2023-03-08 09:38:48 +00:00
Ilya Chernikov 8a8b204e11 K2, stdlib tests: make unsigned conversions explicit
Allow using K2 to compile stdlib tests
related to #KT-56379
2023-03-08 09:38:47 +00:00
Abduqodiri Qurbonzoda dc03a03762 Introduce basic, url-safe and mime Base64 variants #KT-9823 2023-01-16 11:24:49 +00:00
Igor Yakovlev 35340f2f04 [Wasm] Fix stdlib String to Float parse 2022-12-29 11:57:47 +00:00
Abduqodiri Qurbonzoda fff593492d Introduce Common AutoCloseable & use #KT-31066
Co-authored-by: Ilya Gorbunov <Ilya.Gorbunov@jetbrains.com>

Merge-request: KT-MR-8113
Merged-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
2022-12-27 11:50:22 +00:00
Ilya Gorbunov e35ace5d3a Deprecate AbstractDoubleTimeSource
There are too few usages of it, and it can be mostly replaced with AbstractLongTimeSource.
2022-09-19 19:16:40 +00:00
Ilya Gorbunov 57c9d61291 ComparableTimeMark and specialized TimeSource KT-54082
- Introduce ComparableTimeMark interface extending TimeMark,
and TimeSource.WithComparableMarks - a time source that returns such time marks.
- Implement ComparableTimeMark in ValueTimeMark and AbstractLong/DoubleTimeMark classes.
2022-09-19 19:16:40 +00:00
Abduqodiri Qurbonzoda 0db9326105 Introduce a deprecated StringBuilder.append(CharArray, Int, Int) in Common #KT-52336 2022-09-08 14:34:38 +00:00
Abduqodiri Qurbonzoda faedd76b32 Remove deprecation from ConcurrentModificationException constructors #KT-53927
The constructors were introduced in jdk7,
thus their usage was prohibited in Common code.
Now that jvmTarget is 1.8 and jdk8+ is used to compile stdlib,
these constructors are available on all platforms.
2022-09-08 14:01:09 +00:00
Ilya Gorbunov 8b95257143 Reduce the chance shuffle produces an identical permutation in test (part 2) 2022-08-29 22:14:24 +02:00
Vsevolod Tolstopyatov 5054e301be [stdlib] Improve EnumEntries
* Provide short-circuit methods for contract "EnumEntries contains all
  enum entries"
* Make EnumEntries serializable
* Introduce more convenient overload for other backends

#KT-53152


Merge-request: KT-MR-6867
Merged-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
2022-08-22 16:50:28 +00:00
Abduqodiri Qurbonzoda 6c4777dcdd Fix JDK-dependent stdlib tests after advancing jvmTarget 2022-08-17 22:55:43 +03:00
Ilya Gorbunov 1addc23b23 Add range iteration tests for rangeUntil
#KT-52932
2022-07-26 23:52:10 +00:00
Ilya Gorbunov 721508f6dd Add several equality tests for empty open ranges 2022-07-26 18:42:30 +00:00
Ilya Gorbunov 4e31f368d5 Add more info to a flaky assertion, increase wait duration 2022-07-19 20:57:39 +00:00
Vsevolod Tolstopyatov 59ac756f22 Initial implementation of EnumEntries
KT-53152


Merge-request: KT-MR-6656
Merged-by: Vsevolod Tolstopyatov <vsevolod.tolstopyatov@jetbrains.com>
2022-07-15 14:26:50 +00:00
Ilya Gorbunov 3a029b8e80 Fix ValueTimeMark adjustment in rare cases and properly test it 2022-07-01 15:20:22 +00:00
Ilya Gorbunov f422845b9c Test open FP ranges with NaN bound
#KT-52932
2022-07-01 13:11:42 +00:00
Ilya Gorbunov 73084e5a68 Add tests for endExclusive property
Now, after a bootstrap, it's possible to use it

#KT-52932
2022-07-01 13:11:42 +00:00
Vsevolod Tolstopyatov 0c8b31b9ed Clarify specification of Duration.parseIsoString
KT-52778


Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>

Merge-request: KT-MR-6556
Merged-by: Vsevolod Tolstopyatov <vsevolod.tolstopyatov@jetbrains.com>
2022-06-28 07:43:33 +00:00
Ilya Gorbunov 227953a267 Temporarily avoid endExclusive in tests
(until bootstrap)
2022-06-28 00:08:07 +00:00
Ilya Gorbunov 4475b15037 Add tests for open ranges
#KT-52932
2022-06-28 00:08:06 +00:00
Romain Guy 02a3915fdf KT-48232: Implement kotlin.math.cbrt() (cubic roots)
cbrt() is the standard cubic root function that provides several advantages over pow(x, 1.0/3.0):
- Better precision
- Faster
- Behaves better with negative values
2022-06-16 20:27:43 +03:00
Ilya Gorbunov 77cf41c189 Saturate overflowing values when adjusting time marks
KT-46132
2022-04-14 16:54:31 +00:00
Ilya Gorbunov fede70d0d5 Make TimeMark returned by TimeSource.Monotonic a value class
This value class wraps Long on JVM and Native thus reducing allocations
in time measurement scenarios when the default monotonic time source is
statically known.

KT-46132
2022-04-14 16:54:30 +00:00
Ilya Gorbunov 1845e326d1 Hide deprecated Double/FloatArray.contains/indexOf/lastIndexOf 2022-04-12 15:03:40 +00:00
Abduqodiri Qurbonzoda 33fb49f20d Fix JDK7 failing tests 2022-04-06 07:42:58 +00:00
Abduqodiri Qurbonzoda 1cb5cab28f [K/N and WASM] Fix ESCAPE and COMMENTS modes 2022-04-05 15:21:31 +00:00
Abduqodiri Qurbonzoda 9593069cb3 [K/N and WASM] Throw on duplicate group name 2022-04-05 15:21:30 +00:00
Abduqodiri Qurbonzoda 187faa121e Test backreference to group with index zero 2022-04-05 15:21:29 +00:00
Abduqodiri Qurbonzoda 74121b26c0 Test octal literal in regex 2022-04-05 15:21:28 +00:00
Abduqodiri Qurbonzoda 46408ffd9d Fix tests by adjusting to platform behavior 2022-04-05 15:21:27 +00:00
Abduqodiri Qurbonzoda 9c4c1ed557 [K/N and WASM] Implement named capturing group in Regexes #KT-41890 2022-04-05 15:21:26 +00:00
Abduqodiri Qurbonzoda c3f5d03b36 [JS] Support named capture groups in Regex #KT-51775 2022-04-05 15:21:25 +00:00
Ilya Gorbunov 4c461d7864 Add min/max test generator and generated tests
Temporarily exclude these tests from kotlin-stdlib-wasm testing due to KT-51647
2022-04-04 22:33:25 +00:00
Abduqodiri Qurbonzoda 42c9a27b8a Specialize Progression first/last/OrNull functions #KT-42178 2022-04-04 22:27:49 +00:00
Ilya Gorbunov 000165b12b Fix incorrect conversion of Long to String in base 36 in JS KT-48924 2022-03-30 06:13:51 +00:00
Alexander Korepanov d584cfc31d Remove workaround for KT-45620 from NumbersTest.kt. 2022-01-28 17:10:01 +00:00
Ilya Gorbunov a829a6743d KT-50173 Fix Regex.escapeReplacement function in JS 2021-12-12 00:27:31 +00:00
Ilya Gorbunov 64c3aef7ab Reduce the chance shuffle produces an identical permutation in test 2021-12-02 20:58:53 +03:00
Pavel Kunyavskiy 9b366af38b [K/N] Fix String.compareTo on unicode strings
^KT-49873
2021-12-01 07:51:27 +00:00