Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Bug 5587: Give unit test name by __LINE__. #264

Merged
merged 2 commits into from over 1 year ago

4 participants

kennytm Alex Rønne Petersen Damian Ziemba Walter Bright
kennytm

http://d.puremagic.com/issues/show_bug.cgi?id=5587

This commit appends 'Lxx' to the unittest's mangled name. The user can get the line number from the traceback:

5   x       0x000091c5 onAssertErrorMsg + 73
6   x       0x00009206 onUnittestErrorMsg + 26
7   x       0x00013199 _d_unittestm + 45
8   x       0x000019d7 void x.__unittest_fail(int) + 27
9   x       0x00001a0a void x.__unittestL13_1() + 46
                                        ^^^ line 13
added some commits July 19, 2011
kennytm Bug 5587: Give unit test name by __LINE__.
This commit appends 'Lxx' to the unittest's mangled name. The user can get the line number from the traceback:

5   x       0x000091c5 onAssertErrorMsg + 73
6   x       0x00009206 onUnittestErrorMsg + 26
7   x       0x00013199 _d_unittestm + 45
8   x       0x000019d7 void x.__unittest_fail(int) + 27
9   x       0x00001a0a void x.__unittestL13_1() + 46
                                        ^^^ line 13
8f478ac
kennytm Fix build failure: snprintf doesn't exist on Windows. af9cd30
Alex Rønne Petersen
alexrp commented July 07, 2012

This really needs to be merged. It would make debugging so much easier.

Damian Ziemba

Ping on this.

Walter Bright WalterBright merged commit d3669f7 into from September 05, 2012
Walter Bright WalterBright closed this September 05, 2012
Walter Bright WalterBright referenced this pull request from a commit September 05, 2012
Walter Bright merge D2 pull #264 9850e67
Brad Roberts braddr referenced this pull request from a commit October 21, 2012
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit December 24, 2013
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit December 25, 2013
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit December 25, 2013
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit December 25, 2013
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Feb 04, 2012
kennytm Bug 5587: Give unit test name by __LINE__.
This commit appends 'Lxx' to the unittest's mangled name. The user can get the line number from the traceback:

5   x       0x000091c5 onAssertErrorMsg + 73
6   x       0x00009206 onUnittestErrorMsg + 26
7   x       0x00013199 _d_unittestm + 45
8   x       0x000019d7 void x.__unittest_fail(int) + 27
9   x       0x00001a0a void x.__unittestL13_1() + 46
                                        ^^^ line 13
8f478ac
kennytm Fix build failure: snprintf doesn't exist on Windows. af9cd30
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 11 additions and 3 deletions. Show diff stats Hide diff stats

  1. 14  src/func.c
14  src/func.c
@@ -3812,13 +3812,21 @@ void InvariantDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
3812 3812
  * instances per module.
3813 3813
  */
3814 3814
 
3815  
-static Identifier *unitTestId()
  3815
+#if __DMC__ || _MSC_VER
  3816
+#define snprintf _snprintf
  3817
+#endif
  3818
+static Identifier *unitTestId(Loc loc)
3816 3819
 {
3817  
-    return Lexer::uniqueId("__unittest");
  3820
+    char name[24];
  3821
+    snprintf(name, 24, "__unittestL%u_", loc.linnum);
  3822
+    return Lexer::uniqueId(name);
3818 3823
 }
  3824
+#if __DMC__ || _MSC_VER
  3825
+#undef snprintf
  3826
+#endif
3819 3827
 
3820 3828
 UnitTestDeclaration::UnitTestDeclaration(Loc loc, Loc endloc)
3821  
-    : FuncDeclaration(loc, endloc, unitTestId(), STCundefined, NULL)
  3829
+    : FuncDeclaration(loc, endloc, unitTestId(loc), STCundefined, NULL)
3822 3830
 {
3823 3831
 }
3824 3832
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.