summaryrefslogtreecommitdiff
path: root/Tests
AgeCommit message (Collapse)Author
2022-08-29LibRegex: Explicitly check if a character falls into a table-based rangeTimothy Flynn
Previously, for a regex such as /[a-sy-z]/i, we would incorrectly think the character "u" fell into the range "a-s" because neither of the conditions "u > s && U > s" or "u < a && U < a" would be true, resulting in the lookup falling back to assuming the character is in the range. Instead, first explicitly check if the character falls into the range, rather than checking if it falls outside the range. If the explicit checks fail, then we know the character is outside the range.
2022-08-27LibJS: Move intrinsics to the realmLinus Groh
Intrinsics, i.e. mostly constructor and prototype objects, but also things like empty and new object shape now live on a new heap-allocated JS::Intrinsics object, thus completing the long journey of taking all the magic away from the global object. This represents the Realm's [[Intrinsics]] slot in the spec and matches its existing [[GlobalObject]] / [[GlobalEnv]] slots in terms of architecture. In the majority of cases it should now be possibly to fully allocate a regular object without the global object existing, and in fact that's what we do now - the realm is allocated before the global object, and the intrinsics between both :^)
2022-08-27LibGL+LibGPU+LibSoftGPU: Implement texture pixel format supportJelle Raaijmakers
In OpenGL this is called the (base) internal format which is an expectation expressed by the client for the minimum supported texel storage format in the GPU for textures. Since we store everything as RGBA in a `FloatVector4`, the only thing we do in this patch is remember the expected internal format, and when we write new texels we fixate the value for the alpha channel to 1 for two formats that require it. `PixelConverter` has learned how to transform pixels during transfer to support this.
2022-08-27LibGL+LibGPU+LibSoftGPU: Implement flexible pixel format conversionJelle Raaijmakers
A GPU (driver) is now responsible for reading and writing pixels from and to user data. The client (LibGL) is responsible for specifying how the user data must be interpreted or written to. This allows us to centralize all pixel format conversion in one class, `LibSoftGPU::PixelConverter`. For both the input and output image, it takes a specification containing the image dimensions, the pixel type and the selection (basically a clipping rect), and converts the pixels from the input image to the output image. Effectively this means we now support almost all OpenGL 1.5 formats, and all custom logic has disappeared from: - `glDrawPixels` - `glReadPixels` - `glTexImage2D` - `glTexSubImage2D` The new logic is still unoptimized, but on my machine I experienced no noticeable slowdown. :^)
2022-08-27AK: Add `FloatingPoint.h`Jelle Raaijmakers
This is a set of functions that allow you to convert between arbitrary IEEE 754 floating point types, as long as they can be represented within 64 bits. Conversion methods between floats and doubles are provided, as well as a generic `float_to_float()`. Example usage: #include <AK/FloatingPoint.h> double val = 1.234; auto weird_f16 = convert_from_native_double<FloatingPointBits<0, 6, 10>>(val); Signed and unsigned floats are supported, and both NaN and +/-Inf are handled correctly. Values that do not fit in the target floating point type are clamped.
2022-08-26LibCrypto+LibJS: Remove the create_from methods from BigIntegerdavidot
Instead we just use a specific constructor. With this set of constructors using curly braces for constructing is highly recommended. As then it will not do too many implicit conversions which could lead to unexpected loss of data or calling the much slower double constructor. Also to ensure we don't feed (Un)SignedBigInteger infinities we throw RangeError earlier for Durations.
2022-08-26LibCrypto: Add a constructor to (Un)SignedBigInteger taking a doubledavidot
For now this will assume that the double given is exactly representable as an integer, so no NaN, infinity or rounding.
2022-08-26LibCrypto: Make the constructors of (Un)SignedBigInteger templateddavidot
This means it can take any (un)signed word of size at most Word. This means the constructor can be disambiguated if we were to add a double constructor :^). This requires a change in just one test.
2022-08-26LibCrypto: Add a rounding mode to UnsignedBigInteger::to_doubledavidot
This allows using different options for rounding, like IEEE roundTiesToEven, which is the mode that JS requires. Also fix that the last word read from the bigint for the mantissa could be shifted incorrectly leading to incorrect results.
2022-08-25LibTimeZone: Fix tests when ENABLE_TIME_ZONE_DATABASE_DOWNLOAD is OFFTimothy Flynn
2022-08-24LibCrypto: Implement a (mostly) proper to_double for UnsignedBigIntegerdavidot
SignedBigInteger can immediately use this by just negating the double if the sign bit is set. For simple cases (below 2^53) we can just convert via an u64, however above that we need to extract the top 53 bits and use those as the mantissa. This function currently does not behave exactly as the JS spec specifies however it is much less naive than the previous implementation.
2022-08-24LibCrypto: Add a way to compare a SignedBigInteger with a doubledavidot
This supports any double value (except for NaNs) instead of having to cast the double to some smaller type which doesn't work for very large values.
2022-08-24Tests/Kernel: Make sure inaccessible area in TestEFault is actually thatAndreas Kling
We were relying on luck to make the mapping before our first mmap() be inaccessible. Let's make it explicit.
2022-08-23LibJS: Remove {Bytecode::,}Interpreter::global_object()Linus Groh
The basic idea is that a global object cannot just come out of nowhere, it must be associated to a realm - so get it from there, if needed. This is to enforce the changes from all the previous commits by not handing out global objects unless you actually have an initialized realm (either stored somewhere, or the VM's current realm).
2022-08-23LibJS: Pass Realm to define_native_{accessor,function}()Linus Groh
This is needed so that the allocated NativeFunction receives the correct realm, usually forwarded from the Object's initialize() function, rather than using the current realm.
2022-08-23LibJS: Remove GlobalObject parameter from native functionsLinus Groh
2022-08-23LibJS: Replace GlobalObject with VM in ArrayBuffer AOs [Part 11/19]Linus Groh
2022-08-23LibJS: Replace GlobalObject with VM in Reference AOs [Part 6/19]Linus Groh
2022-08-23LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19]Linus Groh
This is where the fun begins. :^)
2022-08-23LibJS: Remove GlobalObject from VM::this_value()Linus Groh
This is a continuation of the previous six commits. The global object is only needed to return it if the execution context stack is empty, but that doesn't seem like a useful thing to allow in the first place - if you're not currently executing JS, and the execution context stack is empty, there is no this value to retrieve.
2022-08-23LibJS: Remove GlobalObject from VM::throw_completion()Linus Groh
This is a continuation of the previous five commits. A first big step into the direction of no longer having to pass a realm (or currently, a global object) trough layers upon layers of AOs! Unlike the create() APIs we can safely assume that this is only ever called when a running execution context and therefore current realm exists. If not, you can always manually allocate the Error and put it in a Completion :^) In the spec, throw exceptions implicitly use the current realm's intrinsics as well: https://tc39.es/ecma262/#sec-throw-an-exception
2022-08-23LibJS+LibWeb: Replace GlobalObject with Realm in Heap::allocate<T>()Linus Groh
This is a continuation of the previous three commits. Now that create() receives the allocating realm, we can simply forward that to allocate(), which accounts for the majority of these changes. Additionally, we can get rid of the realm_from_global_object() in one place, with one more remaining in VM::throw_completion().
2022-08-23LibJS+LibWeb: Replace GlobalObject with Realm in create() functionsLinus Groh
This is a continuation of the previous two commits. As allocating a JS cell already primarily involves a realm instead of a global object, and we'll need to pass one to the allocate() function itself eventually (it's bridged via the global object right now), the create() functions need to receive a realm as well. The plan is for this to be the highest-level function that actually receives a realm and passes it around, AOs on an even higher level will use the "current realm" concept via VM::current_realm() as that's what the spec assumes; passing around realms (or global objects, for that matter) on higher AO levels is pointless and unlike for allocating individual objects, which may happen outside of regular JS execution, we don't need control over the specific realm that is being used there.
2022-08-23LibJS+LibWeb: Replace GlobalObject with Realm in initialize() functionsLinus Groh
This is a continuation of the previous commit. Calling initialize() is the first thing that's done after allocating a cell on the JS heap - and in the common case of allocating an object, that's where properties are assigned and intrinsics occasionally accessed. Since those are supposed to live on the realm eventually, this is another step into that direction.
2022-08-04Tests: Update TestFontHandling and add new testthankyouverycool
Updates BitmapFont testing for fallible writes and adds a new test font file for use in a new un/masking test.
2022-08-04Tests: Add a test for markdown image sizesMacDue
2022-07-27Everywhere: Make the codebase more architecture awareUndefine
2022-07-27LibCore: Implement four-digit modes for `FilePermissionsMask` parsingTim Schumacher
2022-07-27LibCore: Implement the 'X' modifier into `FilePermissionMask`Tim Schumacher
2022-07-22Everywhere: Prefix 'TYPEDEF_DISTINCT_NUMERIC_GENERAL' with 'AK_'Linus Groh
2022-07-22Tests: Add a test for `pthread_cancel`Tim Schumacher
2022-07-22Tests: Add tests for `pthread_setcancel{state,type}`Tim Schumacher
We likely won't be able to test `pthread_cancel` itself, but this at least makes sure that we use the correct values by default and that we correctly reject invalid values.
2022-07-20LibRegex: Partially implement the ECMAScript unicodeSets proposalAli Mohammad Pur
This skips the new string unicode properties additions, along with \q{}.
2022-07-19LibC: Remove the `LibPthread` interface targetTim Schumacher
2022-07-19Tests: Move the LibPthread tests to the correct namespaceTim Schumacher
2022-07-19Everywhere: Refer to `pthread.h` by its non-prefixed nameTim Schumacher
This removes a bit of noise from the following patches, where we will move the `pthread.h` header out of the `LibPthread` directory.
2022-07-14AK: Use the correct data types in bitap_bitwise()Ali Mohammad Pur
Otherwise the bit twiddling goes all wrong and breaks some boundary cases. Fixes `StringView::contains(31-chars)`.
2022-07-12Tests: Remove StringView char const* initialization testsin-ack
We now explicitly disallow this.
2022-07-12AK+Userland+Tests: Remove URL(char const*) constructorsin-ack
The StringView(char const*) constructor is being removed, and there was only a few users of this left, which are also cleaned up in this commit.
2022-07-12Everywhere: Replace single-char StringView op. arguments with charssin-ack
This prevents us from needing a sv suffix, and potentially reduces the need to run generic code for a single character (as contains, starts_with, ends_with etc. for a char will be just a length and equality check). No functional changes.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-12Everywhere: Explicitly specify the size in StringView constructorssin-ack
This commit moves the length calculations out to be directly on the StringView users. This is an important step towards the goal of removing StringView(char const*), as it moves the responsibility of calculating the size of the string to the user of the StringView (which will prevent naive uses causing OOB access).
2022-07-12Tests: Convert TestQuotedPrintable decode test to use StringViewssin-ack
2022-07-12Tests: Convert TestBase64 decode test to use StringViews directlysin-ack
Previously it would rely on the implicit StringView conversions. Now the decode_equal function will directly use StringViews.
2022-07-12Tests: Make TestSourceLocation basic_scenario specify StringView lengthsin-ack
2022-07-10AK: Treat empty string as invalid JSONLuke Wilde
Previously we would treat the empty string as `null`. This caused JavaScript like this to fail: ```js var object = {}; try { object = JSON.parse(""); } catch {} var array = object.array || []; ``` Since `JSON.parse("")` returned null instead of throwing, it would set `object` to null and then try and use it instead of using the default backup value.
2022-07-10LibXML: Fail gracefully on integer overflow in character referencesIdan Horowitz
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47738
2022-07-10LibRegex: Treat inverted Compare entries as disjunctionsAli Mohammad Pur
[^XYZ] is not(X | Y | Z), we used to translate this to not(X) | not(Y) | not(Z), this commit makes LibRegex interpret this pattern as not(X) & not(Y) & not(Z).
2022-07-09AK: Add IPv4Address::netmask_from_cidrMaciej
2022-07-09LibRegex: Fix lookup table-based range checks in CompareAli Mohammad Pur
The lowercase version of a range is not required to be a valid range, instead of casefolding the range and making it invalid, check twice with both cases of the input character (which are the same as the input if not insensitive). This time includes an actual test :^)