summaryrefslogtreecommitdiff
path: root/Tests
AgeCommit message (Collapse)Author
2022-01-22Revert "LibRegex: Implement an ECMA262 Regex quirk with negative loo..."Ali Mohammad Pur
This partially reverts commit c11be92e23d899e28d45f67be24e47b2e5114d3a. That commit fixes one thing and breaks many more, a next commit will implement this quirk in a more sane way.
2022-01-21LibRegex: Allow the pattern to match the zero-length end of the stringAli Mohammad Pur
...only if Multiline is not enabled. Fixes #11940.
2022-01-21LibRegex: Implement an ECMA262 Regex quirk with negative lookaroundsAli Mohammad Pur
This implements the quirk defined by "Note 3" in section "Canonicalize" (https://tc39.es/ecma262/#sec-runtime-semantics-canonicalize-ch). Crosses off another quirk from #6042.
2022-01-21LibRegex: Correct jump offset to the start of the loop blockAli Mohammad Pur
Previously we were jumping to the new end of the previous block (created by the newly inserted ForkStay), correct the offset to jump to the correct block as shown in the comments. Fixes #12033.
2022-01-20Tests: Add should_error_when_connection_fails test to TestLibCoreStreamsin-ack
This test makes sure that Socket classes such as TCPSocket properly return an error when connection fails rather than crashing or creating an invalid object.
2022-01-20Tests: Fix the TestLibCoreStream local_socket_write testsin-ack
Accidentally regressed this test during the Core::LocalServer refactor, and didn't catch it since TestLibCoreStream is disabled in the CI right now. We have to wait for some data to become available, as pending_bytes will immediately return 0 and a 0-sized read immediately returns.
2022-01-19LibJS+LibUnicode: Return the appropriate time zone name depending on DSTTimothy Flynn
2022-01-19LibJS+LibTimeZone+LibUnicode: Indicate whether a time zone is in DSTTimothy Flynn
Return whether the time zone is in DST during the provided time from TimeZone::get_time_zone_offset,
2022-01-19LibJS+LibTimeZone: Begin handling DST when computing time zone offsetsTimothy Flynn
This also updates some expectations in a Temporal time zone offset test that is using a time stamp which is in DST for a few time zones.
2022-01-18LibCrypto+LibJS: Better bitwise binary_xor binopNico Weber
We went through some trouble to make & and | work right. Reimplement ^ in terms of & and | to make ^ work right as well. This is less fast than a direct implementation, but let's get things working first.
2022-01-18LibCrypto+LibJS: Better bigint bitwise_or binopNico Weber
Similar to the bitwise_and change, but we have to be careful to sign-extend two's complement numbers only up to the highest set bit in the positive number.
2022-01-18LibCrypto+LibJS: Better bigint bitwise_and binopNico Weber
Bitwise and is defined in terms of two's complement, so some converting needs to happen for SignedBigInteger's sign/magnitude representation to work out. UnsignedBigInteger::bitwise_not() is repurposed to convert all high-order zero bits to ones up to a limit, for the two's complement conversion to work. Fixes test262/test/language/expressions/bitwise-and/bigint.js.
2022-01-18LibJS+LibCrypto: Fix SignedBitInteger::bitwise_not and use it in LibJSNico Weber
Bitwise operators are defined on two's complement, but SignedBitInteger uses sign-magnitude. Correctly convert between the two. Let LibJS delegate to SignedBitInteger for bitwise_not, like it does for all other bitwise_ operations on bigints. No behavior change (LibJS is now the only client of SignedBitInteger::bitwise_not()).
2022-01-16Tests: Test whether stdio streams are flushed correctly on exitDaniel Bertalan
2022-01-16LibC: Make `*alloc` return `NULL` in case of failure (POSIX)Michel Hermier
2022-01-16LibSQL: Introduce SELECT ... LIMIT xxx OFFSET yyyJan de Visser
What it says on the tin.
2022-01-16LibSQL+SQLServer: Implement first cut of SELECT ... ORDER BY fooJan de Visser
Ordering is done by replacing the straight Vector holding the query result in the SQLResult object with a dedicated Vector subclass that inserts result rows according to their sort key using a binary search. This is done in the ResultSet class. There are limitations: - "SELECT ... ORDER BY 1" (or 2 or 3 etc) is supposed to sort by the n-th result column. This doesn't work yet - "SELECT ... column-expression alias ... ORDER BY alias" is supposed to sort by the column with the given alias. This doesn't work yet What does work however is something like ```SELECT foo FROM bar SORT BY quux``` i.e. sorted by a column not in the result set. Once functions are supported it should be possible to sort by random functions.
2022-01-16AK: Fix logic in String::operator>(const String&)Matt Jacobson
Null strings should not compare greater than non-null strings. Add tests for >, <, >=, and <= comparison involving null strings.
2022-01-15LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServersin-ack
This change unfortunately cannot be atomically made without a single commit changing everything. Most of the important changes are in LibIPC/Connection.cpp, LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp. The notable changes are: - IPCCompiler now generates the decode and decode_message functions such that they take a Core::Stream::LocalSocket instead of the socket fd. - IPC::Decoder now uses the receive_fd method of LocalSocket instead of doing system calls directly on the fd. - IPC::ConnectionBase and related classes now use the Stream API functions. - IPC::ServerConnection no longer constructs the socket itself; instead, a convenience macro, IPC_CLIENT_CONNECTION, is used in place of C_OBJECT and will generate a static try_create factory function for the ServerConnection subclass. The subclass is now responsible for passing the socket constructed in this function to its ServerConnection base; the socket is passed as the first argument to the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before any other arguments. - The functionality regarding taking over sockets from SystemServer has been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket implementation of this functionality hasn't been deleted due to my intention of removing this class in the near future and to reduce noise on this (already quite noisy) PR.
2022-01-14Tests: Unmap memory ranges on /dev/mem after testing mmap(2)Liav A
2022-01-14AK: Make Variant::visit() prefer overloads accepting T const& over T&Ali Mohammad Pur
This makes the following code behave as expected: Variant<int, String> x { some_string() }; x.visit( [](String const&) {}, // Expectation is for this to be called [](auto&) {});
2022-01-14AK+Everywhere: Make Variant::visit() respect the Variant's constnessAli Mohammad Pur
...and fix all the instances of visit() taking non-const arguments.
2022-01-14Tests: Remove some temporary files when finished using themAndreas Kling
Leaving files in /tmp uses memory, which accumulates over time if you do something weird like leaving `run-tests` going all day long. :^)
2022-01-13LibCore+Userland+Tests: Convert Stream APIs to construct on heapsin-ack
As per previous discussion, it was decided that the Stream classes should be constructed on the heap. While I don't personally agree with this change, it does have the benefit of avoiding Function object reconstructions due to the lambda passed to Notifier pointing to a stale object reference. This also has the benefit of not having to "box" objects for virtual usage, as the objects come pre-boxed. However, it means that we now hit the heap everytime we construct a TCPSocket for instance, which might not be desirable.
2022-01-13Tests: Test FixedArray completelykleines Filmröllchen
Except for tangential accessors such as data(), there is no more feature of FixedArray that is untested after this large expansion of its test cases. These tests, with the help of the new NoAllocationGuard, also test the allocation contract that was fixated in the last commit. Hopefully this builds confidence in future Kernel uses of FixedArray as well as its establishment in the real-time parts of the audio subsystem. I'm excited :^)
2022-01-13AK: Remove clear() from FixedArray and fixate its allocation guaranteeskleines Filmröllchen
FixedArray always *almost* had the following allocation guarantees: There is (possibly) one allocation in the constructor and one (or more) deallocation(s) in the destructor. No other operation allocates or deallocates. With this removal of the public clear() method, which nobody except the test used anyways, those guarantees are now completely true and furthermore fixated with an explanatory comment.
2022-01-12LibUnicode: Swap the preferred order of standard time zone display namesTimothy Flynn
Our generator is currently preferring the DST variant of the time zone display names over the non-DST variant. LibTimeZone currently does not have DST support, and operates in a mode that basically assumes DST does not exist. Swap the display names for now just to be consistent until we have DST support. Note we will need to generate both of these variants and select the appropriate one at runtime once we have DST support.
2022-01-11LibUnicode: Parse and generate long and short generic time zone namesTimothy Flynn
This implements the CalendarPatternStyle::{Long,Short}Generic styles of time zone name formatting.
2022-01-11LibUnicode: Fall back to GMT offset when a time zone name is unavailableTimothy Flynn
The following table in TR-35 includes a web of fall back rules when the requested time zone style is unavailable: https://unicode.org/reports/tr35/tr35-dates.html#dfst-zone Conveniently, the subset of styles supported by ECMA-402 (and therefore LibUnicode) all either fall back to GMT offset or to a style that is unsupported but itself falls back to GMT offset.
2022-01-11LibUnicode: Implement TR-35's localized GMT offset formattingTimothy Flynn
This adds an API to use LibTimeZone to convert a time zone such as "America/New_York" to a GMT offset string like "GMT-5" (short form) or "GMT-05:00" (long form).
2022-01-11LibTimeZone: Operate in UTC-only mode when !ENABLE_TIME_ZONE_DATALinus Groh
Instead of only having dummy functions that don't work with any input, let's at least support one time zone: 'UTC'. This matches the basic Temporal implementation for engines without ECMA-262, for example.
2022-01-11AK+Kernel: Remove one_ref_left() footgunAndreas Kling
This mechanism was unsafe to use in any multithreaded context, since the hook function was invoked on a raw pointer *after* decrementing the local ref count. Since we don't use it for anything anymore, let's just get rid of it.
2022-01-11LibTimeZone: Begin generating GMT offset rules for each time zoneTimothy Flynn
This is a rather naive implementation, but serves as a first pass at determining the GMT offset for a time zone at a particular point in time. This implementation ignores DST (because we are not parsing any RULE entries yet), and ignores any offset patterns of the form "Mon>4" or "lastSun".
2022-01-11LibTimeZone: Add methods to canonicalize a time zone nameTimothy Flynn
2022-01-11LibTimeZone: Add method to convert a time zone to a stringTimothy Flynn
2022-01-11LibTimeZone: Perform time-zone-from-string lookups case insensitivelyTimothy Flynn
Time zone names in the TZDB are defined to be case insensitive.
2022-01-11LibTimeZone: Add a unit test for generated time zone dataTimothy Flynn
2022-01-11AK: Define a traits helper for case-insensitive StringView hashingTimothy Flynn
Currently, we define a CaseInsensitiveStringTraits structure for String. Using this structure for StringView involves allocating a String from that view, and a second string to convert that intermediate string to lowercase. This defines CaseInsensitiveStringViewTraits (and the underlying helper case_insensitive_string_hash) to avoid allocations.
2022-01-08AK+Everywhere: Make FixedArray OOM-safecreator1creeper1
FixedArray now doesn't expose any infallible constructors anymore. Rather, it exposes fallible methods. Therefore, it can be used for OOM-safe code. This commit also converts the rest of the system to use the new API. However, as an example, VMObject can't take advantage of this yet, as we would have to endow VMObject with a fallible static construction method, which would require a very fundamental change to VMObject's whole inheritance hierarchy.
2022-01-08Tests: Add test cases for #10702 and #10717Simon Woertz
Add test cases for parsing an empty file and a truncated file.
2022-01-08Tests: Add base structure for LibPDF unit testsSimon Woertz
Add a unit test for each sample pdf file that currently exists in the anon user's `~/Document/pdf` directory. - linear.pdf - non-linearized.pdf - complex.pdf Each test ensures that the pdf document is parsed and that the page count is the expected one.
2022-01-08Kernel: Implement read functionality for MemoryDeviceLiav A
So far we only had mmap(2) functionality on the /dev/mem device, but now we can also do read(2) on it. The test unit was updated to check we are doing it safely.
2022-01-07Everywhere: Fix spelling mistakesmjz19910
2022-01-07AK: Use a full-period xorshift PRNG for double_hashSchlufi
The previous implementation had some pretty short cycles and two fixed points (1711463637 and 2389024350). If two keys hashed to one of these values insertions and lookups would loop forever. This version is based on a standard xorshift PRNG with period 2**32-1. The all-zero state is usually forbidden, so we insert it into the cycle at an arbitrary location.
2022-01-07Everywhere: Fix many spelling errorsmjz19910
2022-01-07LibSQL: Implement LIKE SQL expressionsGuilherme Gonçalves
2022-01-07LibSQL: Properly parse ESCAPE expressionsGuilherme Gonçalves
The evaluation order of method parameters is unspecified in C++, and so we couldn't rely on parse_statement() being called before parse_escape() when building a MatchExpression. With this patch, we explicitly parse what we need in the right order, before building the MatchExpression object.
2022-01-06LibUnicode: Do not assume time zones & meta zones have a 1-to-1 mappingTimothy Flynn
The generator parses metaZones.json to form a mapping of meta zones to time zones (AKA "golden zone" in TR-35). This parser errantly assumed this was a 1-to-1 mapping.
2022-01-06AK: Ensure negative predicate in TestHashMap could run unsuccessfullyNHOrus
As it was, negative predicate test for remove_all_matching was run on empty hash map, and could not remove anything, so test always returned true. By duplicating it in state where hash maps contains elements, we make sure that negative predicate has something to do nothing on.
2022-01-05AK: Improve HashTable::remove_all_matching() test slightlyAndreas Kling
After removing some entries, we now also verify that the correct entries remain in the table. :^)