Topic: [Idea] unit tests
Author: koczurekk@gmail.com
Date: Sat, 14 Oct 2017 07:24:05 -0700 (PDT)
Raw View
------=_Part_14155_1011959256.1507991045412
Content-Type: multipart/alternative;
boundary="----=_Part_14156_1836250301.1507991045412"
------=_Part_14156_1836250301.1507991045412
Content-Type: text/plain; charset="UTF-8"
Currently C++ requires additional frameworks to provide any decent unit
tests and it requires a lot of macros. Some other languages, like D,
provide built-in unit tests as a part of the language and it makes code a
lot cleaner. I personally really like UT implementation in D, you can take
a look at it here <https://dlang.org/spec/unittest.html>.
Do you think C++ would benefit from such feature? Why (not)?
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/043ad5c2-2abe-4f4a-8bf0-8451da351209%40isocpp.org.
------=_Part_14156_1836250301.1507991045412
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Currently C++ requires additional frameworks to provide an=
y decent unit tests and it requires a lot of macros. Some other languages, =
like D, provide built-in unit tests as a part of the language and it makes =
code a lot cleaner. I personally really like UT implementation in D, you ca=
n take a look at it <a href=3D"https://dlang.org/spec/unittest.html">here</=
a>.<div>Do you think C++ would benefit from such feature? Why (not)?<br></d=
iv></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/043ad5c2-2abe-4f4a-8bf0-8451da351209%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/043ad5c2-2abe-4f4a-8bf0-8451da351209=
%40isocpp.org</a>.<br />
------=_Part_14156_1836250301.1507991045412--
------=_Part_14155_1011959256.1507991045412--
.
Author: Magnus Fromreide <magfr@lysator.liu.se>
Date: Sat, 14 Oct 2017 17:32:03 +0200
Raw View
On Sat, Oct 14, 2017 at 07:24:05AM -0700, koczurekk@gmail.com wrote:
> Currently C++ requires additional frameworks to provide any decent unit
> tests and it requires a lot of macros. Some other languages, like D,
> provide built-in unit tests as a part of the language and it makes code a
> lot cleaner. I personally really like UT implementation in D, you can take
> a look at it here <https://dlang.org/spec/unittest.html>.
> Do you think C++ would benefit from such feature? Why (not)?
Do you have anything different than
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4420.pdf
in mind?
/MF
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/20171014153154.GA1546%40fukushima.lysator.liu.se.
.
Author: John McFarlane <john@mcfarlane.name>
Date: Sat, 14 Oct 2017 15:36:26 +0000
Raw View
--001a11452abefa3cec055b838922
Content-Type: text/plain; charset="UTF-8"
On Sat, Oct 14, 2017 at 8:32 AM Magnus Fromreide <magfr@lysator.liu.se>
wrote:
> On Sat, Oct 14, 2017 at 07:24:05AM -0700, koczurekk@gmail.com wrote:
> > Currently C++ requires additional frameworks to provide any decent unit
> > tests and it requires a lot of macros. Some other languages, like D,
> > provide built-in unit tests as a part of the language and it makes code a
> > lot cleaner. I personally really like UT implementation in D, you can
> take
> > a look at it here <https://dlang.org/spec/unittest.html>.
> > Do you think C++ would benefit from such feature? Why (not)?
>
> Do you have anything different than
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4420.pdf
>
> in mind?
>
D's solution goes further than the proposal, addressing some of the
features listed under "Not Included in this Proposal", most notably a means
for running the tests. It also doesn't require that each test be in a
function with name and return type etc..
>
> /MF
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/20171014153154.GA1546%40fukushima.lysator.liu.se
> .
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CABPJVnSW003ZosqxDBC8%3DxbYb%3DCdHrHRQaKc%2Bza%3DSFS221VQdA%40mail.gmail.com.
--001a11452abefa3cec055b838922
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Sat, Oct 14, 2017 at 8:32 AM Magnus Fromreide <<a hr=
ef=3D"mailto:magfr@lysator.liu.se">magfr@lysator.liu.se</a>> wrote:<br><=
div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin=
:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, Oct 14, 20=
17 at 07:24:05AM -0700, <a href=3D"mailto:koczurekk@gmail.com" target=3D"_b=
lank">koczurekk@gmail.com</a> wrote:<br>
> Currently C++ requires additional frameworks to provide any decent uni=
t<br>
> tests and it requires a lot of macros. Some other languages, like D,<b=
r>
> provide built-in unit tests as a part of the language and it makes cod=
e a<br>
> lot cleaner. I personally really like UT implementation in D, you can =
take<br>
> a look at it here <<a href=3D"https://dlang.org/spec/unittest.html"=
rel=3D"noreferrer" target=3D"_blank">https://dlang.org/spec/unittest.html<=
/a>>.<br>
> Do you think C++ would benefit from such feature? Why (not)?<br>
<br>
Do you have anything different than<br>
<br>
<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4420.pd=
f" rel=3D"noreferrer" target=3D"_blank">http://www.open-std.org/jtc1/sc22/w=
g21/docs/papers/2015/n4420.pdf</a><br>
<br>
in mind?<br></blockquote><div><br></div><div>D's solution goes further =
than the proposal, addressing some of the features listed under "Not I=
ncluded in this Proposal", most notably a means for running the tests.=
=C2=A0 It also doesn't require that each test be in a function with nam=
e and return type etc.. <br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
/MF<br>
<br>
--<br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/20171014153154.GA1546%40fukushima.lys=
ator.liu.se" rel=3D"noreferrer" target=3D"_blank">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/20171014153154.GA1546%40fukushima.lysat=
or.liu.se</a>.<br>
</blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CABPJVnSW003ZosqxDBC8%3DxbYb%3DCdHrHR=
QaKc%2Bza%3DSFS221VQdA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CABPJVnSW=
003ZosqxDBC8%3DxbYb%3DCdHrHRQaKc%2Bza%3DSFS221VQdA%40mail.gmail.com</a>.<br=
/>
--001a11452abefa3cec055b838922--
.
Author: John McFarlane <john@mcfarlane.name>
Date: Sat, 14 Oct 2017 15:49:36 +0000
Raw View
--001a113f2248078b3b055b83b9a1
Content-Type: text/plain; charset="UTF-8"
On Sat, Oct 14, 2017 at 7:24 AM <koczurekk@gmail.com> wrote:
> Currently C++ requires additional frameworks to provide any decent unit
> tests and it requires a lot of macros. Some other languages, like D,
> provide built-in unit tests as a part of the language and it makes code a
> lot cleaner. I personally really like UT implementation in D, you can take
> a look at it here <https://dlang.org/spec/unittest.html>.
> Do you think C++ would benefit from such feature? Why (not)?
>
It might but perhaps not that much.
Firstly, whenever a library can provide the same functionality as a
language feature, the former tends to be favored. D's `unittest` -- while
clean and convenient are far necessary.
Regarding macros, C++ is gradually seeking out superior solutions in cases
where macros are used currently. A good example here is finding an
alternative to macros that use `__LINE__` and `__FILE__`[1]. Generally, I
would expect many of the disadvantages of C++ test frameworks to be
addressed over time with general solutions that extend far beyond this one
use case.
Some people are very used to separating tests from the code that is being
tested -- often into an entirely different project root directory. This
can be an obstacle to acceptance of a feature which aims to improve
locality -- as D tests tend to.
Then there are the alternatives. `static_assert` does not require
additional frameworks to function and does not even incur a runtime cost.
For the diminishing number of tests that cannot be performed at compile
time, `assert` and contracts[2] -- while not solely intended for the
purpose of unit testing -- play a significant role in testing code and
ensuring correctness.
So overall, I would not be too hopeful for such a proposal per se but I'm
in favor of improvements that head in the same general direction.
Thanks,
John
1. wg21.link/N4519
2. wg21.link/P0542R1
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CABPJVnS%3D%2BQGQzQynbhfGDSwCKWUSkvO4JDztPsSoxVi4aq%3DNDQ%40mail.gmail.com.
--001a113f2248078b3b055b83b9a1
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_quote"><div dir=3D"ltr">On Sat, Oct 14=
, 2017 at 7:24 AM <<a href=3D"mailto:koczurekk@gmail.com" target=3D"_bla=
nk">koczurekk@gmail.com</a>> wrote:<br></div><blockquote class=3D"gmail_=
quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
ex"><div dir=3D"ltr">Currently C++ requires additional frameworks to provid=
e any decent unit tests and it requires a lot of macros. Some other languag=
es, like D, provide built-in unit tests as a part of the language and it ma=
kes code a lot cleaner. I personally really like UT implementation in D, yo=
u can take a look at it <a href=3D"https://dlang.org/spec/unittest.html" ta=
rget=3D"_blank">here</a>.<div>Do you think C++ would benefit from such feat=
ure? Why (not)?<br></div></div></blockquote><div><br></div></div><div dir=
=3D"ltr"><div class=3D"gmail_quote"><div>It might but perhaps not that much=
..=C2=A0 <br></div><br><div>Firstly, whenever a library can provide the same=
functionality as a language feature, the former tends to be favored.=C2=A0=
D's `unittest` -- while clean and convenient are far necessary.<br></d=
iv><div><br></div><div>Regarding macros, C++ is gradually seeking out super=
ior solutions in cases where macros are used currently.=C2=A0 A good exampl=
e here is finding an alternative to macros that use `__LINE__` and `__FILE_=
_`[1].=C2=A0 Generally, I would expect many of the disadvantages of C++ tes=
t frameworks to be addressed over time with general solutions that extend f=
ar beyond this one use case.<br></div><div><br></div><div>Some people are v=
ery used to separating tests from the code that is being tested -- often in=
to an entirely different project root directory.=C2=A0 This can be an obsta=
cle to acceptance of a feature which aims to improve locality -- as D tests=
tend to.</div><div><br></div><div>Then there are the alternatives.=C2=A0 `=
static_assert` does not require additional frameworks to function and does =
not even incur a runtime cost.=C2=A0 For the diminishing number of tests th=
at cannot be performed at compile time, `assert` and contracts[2] -- while =
not solely intended for the purpose of unit testing -- play a significant r=
ole in testing code and ensuring correctness.</div><div><br></div><div>So o=
verall, I would not be too hopeful for such a proposal per se but I'm i=
n favor of improvements that head in the same general direction.</div><div>=
<br></div><div>Thanks,</div><div>John<br></div><div><br></div><div>1. wg21.=
link/N4519<br></div><div>2. wg21.link/P0542R1</div></div></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CABPJVnS%3D%2BQGQzQynbhfGDSwCKWUSkvO4=
JDztPsSoxVi4aq%3DNDQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CABPJVnS%3D=
%2BQGQzQynbhfGDSwCKWUSkvO4JDztPsSoxVi4aq%3DNDQ%40mail.gmail.com</a>.<br />
--001a113f2248078b3b055b83b9a1--
.