Skip to content

Commit

Permalink
Refactor Comparison Functions, update wat files, add toBlockEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
jtenner committed May 24, 2019
1 parent e88c7c3 commit 846ca1f
Show file tree
Hide file tree
Showing 42 changed files with 18,197 additions and 28,484 deletions.
132 changes: 78 additions & 54 deletions assembly/__tests__/addedFiles.spec.wat
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
(type $FUNCSIG$viii (func (param i32 i32 i32)))
(type $FUNCSIG$vi (func (param i32)))
(import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32)))
(import "__aspect" "reportActualValue" (func $assembly/internal/Expectation/reportActualInteger (param i32)))
(import "__aspect" "reportExpectedValue" (func $assembly/internal/Expectation/reportExpectedInteger (param i32 i32)))
(import "__aspect" "clearExpected" (func $assembly/internal/Expectation/clearExpected))
(import "__aspect" "reportActualValue" (func $assembly/internal/report/reportActual/reportActualInteger (param i32)))
(import "__aspect" "reportExpectedValue" (func $assembly/internal/report/reportExpected/reportExpectedInteger (param i32 i32)))
(import "__aspect" "clearExpected" (func $assembly/internal/comparison/exactComparison/clearExpected))
(import "__aspect" "reportTest" (func $assembly/internal/Test/reportTest (param i32 i32)))
(import "__aspect" "reportDescribe" (func $assembly/internal/Describe/reportDescribe (param i32)))
(import "__aspect" "reportEndDescribe" (func $assembly/internal/Describe/reportEndDescribe))
Expand All @@ -23,8 +23,8 @@
(data (i32.const 256) "\16\00\00\00\01\00\00\00\01\00\00\00\16\00\00\00a\00d\00d\00e\00d\00 \00f\00i\00l\00e\00s\00")
(data (i32.const 296) "N\00\00\00\01\00\00\00\01\00\00\00N\00\00\00s\00h\00o\00u\00l\00d\00 \00r\00e\00a\00d\00 \00g\00l\00o\00b\00a\00l\00s\00 \00f\00r\00o\00m\00 \00i\00n\00c\00l\00u\00d\00e\00d\00 \00f\00i\00l\00e\00s\00")
(data (i32.const 392) "\00\00\00\00\01\00\00\00\01\00\00\00\00\00\00\00")
(data (i32.const 408) "@\00\00\00\01\00\00\00\01\00\00\00@\00\00\00a\00s\00s\00e\00m\00b\00l\00y\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00E\00x\00p\00e\00c\00t\00a\00t\00i\00o\00n\00.\00t\00s\00")
(data (i32.const 488) "\04\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00")
(data (i32.const 408) "^\00\00\00\01\00\00\00\01\00\00\00^\00\00\00a\00s\00s\00e\00m\00b\00l\00y\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00c\00o\00m\00p\00a\00r\00i\00s\00o\00n\00/\00e\00x\00a\00c\00t\00C\00o\00m\00p\00a\00r\00i\00s\00o\00n\00.\00t\00s\00")
(data (i32.const 520) "\04\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00\08\00\00\00\00\00\00\00")
(table $0 4 funcref)
(elem (i32.const 0) $null $start:assembly/__tests__/addedFiles.spec~anonymous|0~anonymous|0 $start:assembly/__tests__/addedFiles.spec~anonymous|0 $start:assembly/internal/noOp~anonymous|0)
(global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0))
Expand All @@ -34,8 +34,9 @@
(global $assembly/__tests__/setup/Test.include/meaningOfLife i32 (i32.const 42))
(global $assembly/internal/noOp/noOp i32 (i32.const 3))
(global $~lib/argc (mut i32) (i32.const 0))
(global $~lib/rt/RTTI_BASE i32 (i32.const 488))
(global $~lib/heap/HEAP_BASE i32 (i32.const 524))
(global $~lib/started (mut i32) (i32.const 0))
(global $~lib/rt/RTTI_BASE i32 (i32.const 520))
(global $~lib/heap/HEAP_BASE i32 (i32.const 556))
(export "memory" (memory $0))
(export "__alloc" (func $~lib/rt/tlsf/__alloc))
(export "__realloc" (func $~lib/rt/tlsf/__realloc))
Expand All @@ -46,8 +47,8 @@
(export "__instanceof" (func $~lib/rt/__instanceof))
(export "__typeinfo" (func $~lib/rt/__typeinfo))
(export "meaningOfLife" (global $assembly/__tests__/setup/Test.include/meaningOfLife))
(export "__main" (func $assembly/index/__main))
(export "__call" (func $assembly/internal/call/__call))
(start $start)
(func $~lib/rt/tlsf/removeBlock (; 7 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
Expand Down Expand Up @@ -2421,25 +2422,17 @@
local.get $0
call $assembly/internal/Expectation/Expectation<i32>#constructor
)
(func $assembly/internal/Expectation/Expectation<i32>#reportActual (; 37 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
i32.load offset=4
call $assembly/internal/Expectation/reportActualInteger
)
(func $assembly/internal/Expectation/Expectation<i32>#reportExpected (; 38 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $1
local.get $0
i32.load
call $assembly/internal/Expectation/reportExpectedInteger
)
(func $assembly/internal/Expectation/Expectation<i32>#cleanup (; 39 ;) (type $FUNCSIG$vi) (param $0 i32)
call $assembly/internal/Expectation/clearExpected
)
(func $start:assembly/__tests__/addedFiles.spec~anonymous|0~anonymous|0 (; 40 ;) (type $FUNCSIG$v)
(func $start:assembly/__tests__/addedFiles.spec~anonymous|0~anonymous|0 (; 37 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
(local $9 i32)
block $assembly/internal/Expectation/Expectation<i32>#toBe|inlined.0
global.get $assembly/__tests__/setup/Test.include/meaningOfLife
call $assembly/internal/Expectation/expect<i32>
Expand All @@ -2450,36 +2443,58 @@
i32.const 408
call $~lib/rt/pure/__retain
local.set $1
local.get $3
call $assembly/internal/Expectation/Expectation<i32>#reportActual
local.get $3
local.get $2
call $assembly/internal/Expectation/Expectation<i32>#reportExpected
local.get $3
i32.load
local.get $2
local.get $3
i32.load offset=4
i32.eq
i32.xor
i32.eqz
if
block $assembly/internal/comparison/exactComparison/exactComparison<i32>|inlined.0
local.get $3
i32.load offset=4
local.set $7
local.get $2
local.set $6
local.get $3
i32.load
local.set $5
local.get $1
i32.const 424
i32.const 106
i32.const 4
call $~lib/builtins/abort
unreachable
call $~lib/rt/pure/__retain
local.set $4
block $assembly/internal/report/reportActual/reportActual<i32>|inlined.0
local.get $7
local.set $8
local.get $8
call $assembly/internal/report/reportActual/reportActualInteger
end
block $assembly/internal/report/reportExpected/reportExpected<i32>|inlined.0
local.get $6
local.set $9
local.get $5
local.set $8
local.get $9
local.get $8
call $assembly/internal/report/reportExpected/reportExpectedInteger
end
local.get $5
local.get $6
local.get $7
i32.eq
i32.xor
i32.eqz
if
local.get $4
i32.const 424
i32.const 17
i32.const 2
call $~lib/builtins/abort
unreachable
end
call $assembly/internal/comparison/exactComparison/clearExpected
local.get $4
call $~lib/rt/pure/__release
end
local.get $3
call $assembly/internal/Expectation/Expectation<i32>#cleanup
local.get $1
call $~lib/rt/pure/__release
end
local.get $0
call $~lib/rt/pure/__release
)
(func $assembly/internal/Test/it (; 41 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(func $assembly/internal/Test/it (; 38 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0
call $~lib/rt/pure/__retain
drop
Expand All @@ -2489,15 +2504,15 @@
local.get $0
call $~lib/rt/pure/__release
)
(func $start:assembly/__tests__/addedFiles.spec~anonymous|0 (; 42 ;) (type $FUNCSIG$v)
(func $start:assembly/__tests__/addedFiles.spec~anonymous|0 (; 39 ;) (type $FUNCSIG$v)
i32.const 312
i32.const 1
call $assembly/internal/Test/it
)
(func $start:assembly/internal/noOp~anonymous|0 (; 43 ;) (type $FUNCSIG$v)
(func $start:assembly/internal/noOp~anonymous|0 (; 40 ;) (type $FUNCSIG$v)
nop
)
(func $assembly/internal/Describe/describe (; 44 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(func $assembly/internal/Describe/describe (; 41 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
local.get $0
call $~lib/rt/pure/__retain
drop
Expand All @@ -2511,21 +2526,30 @@
local.get $0
call $~lib/rt/pure/__release
)
(func $start:assembly/__tests__/addedFiles.spec (; 45 ;) (type $FUNCSIG$v)
(func $start:assembly/__tests__/addedFiles.spec (; 42 ;) (type $FUNCSIG$v)
i32.const 272
i32.const 2
call $assembly/internal/Describe/describe
)
(func $assembly/internal/call/__call (; 46 ;) (type $FUNCSIG$vi) (param $0 i32)
(func $assembly/index/__main (; 43 ;) (type $FUNCSIG$v)
global.get $~lib/started
i32.eqz
if
call $start
i32.const 1
global.set $~lib/started
end
)
(func $assembly/internal/call/__call (; 44 ;) (type $FUNCSIG$vi) (param $0 i32)
i32.const 0
global.set $~lib/argc
local.get $0
call_indirect (type $FUNCSIG$v)
)
(func $start (; 47 ;) (type $FUNCSIG$v)
(func $start (; 45 ;) (type $FUNCSIG$v)
call $start:assembly/__tests__/addedFiles.spec
)
(func $~lib/rt/pure/__visit (; 48 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(func $~lib/rt/pure/__visit (; 46 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
(local $3 i32)
local.get $0
Expand Down Expand Up @@ -2679,7 +2703,7 @@
end
end
)
(func $~lib/rt/__visit_members (; 49 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(func $~lib/rt/__visit_members (; 47 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
block
end
Expand Down Expand Up @@ -2736,6 +2760,6 @@
unreachable
end
)
(func $null (; 50 ;) (type $FUNCSIG$v)
(func $null (; 48 ;) (type $FUNCSIG$v)
)
)
16 changes: 14 additions & 2 deletions assembly/__tests__/as-pect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,9 @@ declare class Expectation<T> {

/**
* This expectation performs a strict equality on value types and performs a memcompare on
* reference types. If the reference type T has reference types as properties, the comparison does
* not perform property traversal. It will only compare the pointer values in the memory block.
* reference types. If the reference type `T` has reference types as properties, the comparison does
* not perform property traversal. It will only compare the pointer values in the memory block, and
* only compare `offsetof<T>()` bytes, regardless of the allocated block size.
*
* @param {T | null} expected - The value to be compared.
* @param {string} message - The optional message that describes the expectation.
Expand All @@ -233,6 +234,17 @@ declare class Expectation<T> {
*/
toStrictEqual(expected: T | null, message?: string): void;

/**
* This expectation performs a strict memory block equality based on the allocated block sizes.
*
* @param {T | null} expected - The value to be compared.
* @param {string} message - The optional message that describes the expectation.
*
* @example
* expect<Vec3>(new Vec3(1, 2, 3)).toBlockEqual(new Vec(1, 2, 3), "Vectors of the same shape should be equal");
*/
toBlockEqual(expected: T | null, message?: string): void;

/**
* If the value is callable, it calls the function, and fails the expectation if it throws, or hits
* an unreachable().
Expand Down
Loading

0 comments on commit 846ca1f

Please sign in to comment.