Page Menu
Home
Search
Configure Global Search
Log In
Paste
P2903
(An Untitled Masterwork)
Active
Public
Actions
Authored by
Jacques Lucke (JacquesLucke)
on Apr 21 2022, 11:10 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Subscribers
None
TEST
(
multi_function_procedure
,
OutputBufferReplaced
)
{
MFProcedure
procedure
;
MFProcedureBuilder
builder
{
procedure
};
const
bool
default_output
=
false
;
CustomMF_GenericConstant
constant_fn
(
CPPType
::
get
<
bool
>
(),
&
default_output
,
false
);
CustomMF_SI_SI_SO
<
int
,
int
,
bool
>
equal_fn
{
"Equal"
,
[](
int
a
,
int
b
)
{
return
a
==
b
;
}};
CustomMF_GenericCopy
copy_fn
(
MFDataType
::
ForSingle
<
bool
>
());
// NOTE: other tests would create variables first (through builder.call<>) and then declare the
// output param at the end!
MFVariable
&
var_o
=
procedure
.
new_variable
(
MFDataType
::
ForSingle
<
bool
>
());
builder
.
add_output_parameter
(
var_o
);
MFVariable
*
var_a
=
&
builder
.
add_single_input_parameter
<
int
>
();
MFVariable
*
var_b
=
&
builder
.
add_single_input_parameter
<
int
>
();
builder
.
add_call_with_all_variables
(
constant_fn
,
{
&
var_o
});
auto
[
temp_out
]
=
builder
.
add_call
<
1
>
(
equal_fn
,
{
var_a
,
var_b
});
builder
.
add_destruct
(
var_o
);
builder
.
add_call_with_all_variables
(
copy_fn
,
{
temp_out
,
&
var_o
});
builder
.
add_destruct
(
*
temp_out
);
builder
.
add_destruct
(
*
var_a
);
builder
.
add_destruct
(
*
var_b
);
builder
.
add_return
();
EXPECT_TRUE
(
procedure
.
validate
());
MFProcedureExecutor
procedure_fn
{
procedure
};
Array
<
int
>
input1
=
{
30
,
5
,
0
};
Array
<
int
>
input2
=
{
-4
,
5
,
-0
};
Array
<
bool
>
output
(
input1
.
size
());
fn
::
MFParamsBuilder
params
(
procedure_fn
,
input1
.
size
());
params
.
add_uninitialized_single_output
(
output
.
as_mutable_span
());
params
.
add_readonly_single_input
(
input1
.
as_span
());
params
.
add_readonly_single_input
(
input2
.
as_span
());
fn
::
MFContextBuilder
context
;
procedure_fn
.
call
(
IndexMask
(
input1
.
size
()),
params
,
context
);
EXPECT_FALSE
(
output
[
0
]);
EXPECT_TRUE
(
output
[
1
]);
EXPECT_TRUE
(
output
[
2
]);
}
Event Timeline
Jacques Lucke (JacquesLucke)
created this paste.
Apr 21 2022, 11:10 AM
Log In to Comment