Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit694536e

Browse files
committed
Fix =default constructor/destructor detection
... apparently the unit tests were totally broken, go figure
1 parent4ecb8a4 commit694536e

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

‎CppHeaderParser/CppHeaderParser.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,6 +2233,9 @@ def parse_method_type(self, stack):
22332233
info["pure_virtual"]=True
22342234
elifstack[-2]=="delete":
22352235
info["deleted"]=True
2236+
elifstack[-2]=="default":
2237+
info["default"]=True
2238+
info["defined"]=True
22362239

22372240
r=header.split()
22382241
name=None
@@ -2274,15 +2277,9 @@ def parse_method_type(self, stack):
22742277

22752278
ifname.startswith("~"):
22762279
info["destructor"]=True
2277-
if"default;"instack:
2278-
info["defined"]=True
2279-
info["default"]=True
22802280
name=name[1:]
22812281
elifnotaor (name==self.curClassandlen(self.curClass)):
22822282
info["constructor"]=True
2283-
if"default;"instack:
2284-
info["defined"]=True
2285-
info["default"]=True
22862283

22872284
info["name"]=name
22882285

‎test/TestSampleClass.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,13 +780,13 @@ int non_vararg_func(int foo, const char* fmt);
780780
classDefaultConstDest {
781781
public:
782782
DefaultConstDest() =default ;// spacing check
783-
DefaultConstDest() =default ;// spacing check
783+
~DefaultConstDest() =default ;// spacing check
784784
};
785785
// default constructor on a class containing "default" as name (edge case check)
786786
classdefault_class_tricky {
787787
public:
788788
default_class_tricky();
789-
default_class_tricky();
789+
~default_class_tricky();
790790

791791
voidrandomMethod1_default();
792792
voiddefaultrandomMethod2();

‎test/test_CppHeaderParser.py‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2648,7 +2648,7 @@ def test_Grackle_const_noexcept_noexcept_operator(self):
26482648

26492649

26502650
# Test enhancement 13 (default constructor / destructor)
2651-
classDefaultConstDest_TestCase:
2651+
classDefaultConstDest_TestCase(unittest.TestCase):
26522652
defsetUp(self):
26532653
self.cppHeader=CppHeaderParser.CppHeader("TestSampleClass.h")
26542654

@@ -3807,6 +3807,24 @@ def test_fn(self):
38073807
self.assertEqual(props[1]["name"],"y")
38083808

38093809

3810+
classDefault_TestCase(unittest.TestCase):
3811+
defsetUp(self):
3812+
self.cppHeader=CppHeaderParser.CppHeader(
3813+
"""
3814+
class A {
3815+
public:
3816+
A() = default;
3817+
};
3818+
""",
3819+
"string",
3820+
)
3821+
3822+
deftest_fn(self):
3823+
m=self.cppHeader.classes["A"]["methods"]["public"][0]
3824+
self.assertEqual(m["constructor"],True)
3825+
self.assertEqual(m["default"],True)
3826+
3827+
38103828
classDeleted_TestCase(unittest.TestCase):
38113829
defsetUp(self):
38123830
self.cppHeader=CppHeaderParser.CppHeader(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp