On 2015/05/12 05:15:41, Benedikt Meurer wrote:

https://codereview.chromium.org/1128133003/diff/1/test/unittests/compiler/machine-operator-unittest.cc
File test/unittests/compiler/machine-operator-unittest.cc (right):


https://codereview.chromium.org/1128133003/diff/1/test/unittests/compiler/machine-operator-unittest.cc#newcode208
test/unittests/compiler/machine-operator-unittest.cc:208: PURE(Word32And, 2,
0,
1);
On 2015/05/11 11:55:29, titzer wrote:
> On 2015/05/07 04:48:38, Benedikt Meurer wrote:
> > This is a lot of boilerplate and macroism and indirection for no obvious > > benefit. Why didn't you implement the loop that we talked about yesterday?
> I.e.
> > something simple like this:
> >
> > namespace {
> >
> > struct PureOperator {
> >   const Operator* (MachineOperatorBuilder::*constructor)();
> >   char const* const constructor_name;
> >   int value_input_count;
> >   int control_input_count;
> >   int value_output_count;
> > };
> >
> >
> > std::ostream& operator<<(std::ostream& os, PureOperator  const& pop) {
> >   return os << pop.constructor_name;
> > }
> >
> > const PureOperator kPureOperators[] = {
> > #define PURE(Name, value_input_count, control_input_count,
value_output_count)
> > {&MachineOperatorBuilder::Name, #Name,value_input_count,
control_input_count,
> > value_output_count}
> >   PURE(Word32Or, 2, 0, 1),
> >   ...
> > #undef PURE
> > };
> >
> > }  // namespace
> >
> >
> > TEST_F(MachineOperatorTest, PureOperators) {
> >   TRACED_FOREACH(MachineType, machine_rep1, kMachineReps) {
> >     MachineOperatorBuilder machine1(zone(), machine_rep1);
> >     TRACED_FOREACH(MachineType, machine_rep2, kMachineReps) {
> >       MachineOperatorBuilder machine2(zone(), machine_rep2);
> >       TRACED_FOREACH(PureOperator, pop, kPureOperators) {
> >         const Operator* op1 = (machine1.pop.constructor)();
> >         const Operator* op2 = (machine2.pop.constructor)();
> >         EXPECT_EQ(op1, op2);
> >         EXPECT_EQ(pop.value_input_count, op1->ValueInputCount());
> >         EXPECT_EQ(pop.control_input_count, op1->ControlInputCount());
> >         EXPECT_EQ(pop.value_output_count, op1->ValueOutputCount());
> >       }
> >     }
> >   }
> > }
> >
> > Same for the optional ones. Move it to the last section in the file,
> > MachineOperatorTest is already there.
>
> I can inline the helper functions into the macro, but I don't see how the
> TRACED_FOR_EACH with a global array of data would be better than just
> enumerating them directly in the test function.

What's the point of putting everything into the macro if you can solve it in
an
elegant way instead that involves only a trivial macro to initialize array
elements?

Done

https://codereview.chromium.org/1128133003/

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to