[DFAJumpThreading] Remove incoming StartBlock from all phis when unfolding select...
[llvm-project.git] / clang / tools / include-mapping / test.py
blobeef328381f2bbe2e62ef76c08728f1eb584332b1
1 #!/usr/bin/env python
2 # ===- test.py - ---------------------------------------------*- python -*--===#
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 # ===------------------------------------------------------------------------===#
10 from cppreference_parser import _ParseSymbolPage, _ParseIndexPage
12 import unittest
15 class TestStdGen(unittest.TestCase):
16 def testParseIndexPage(self):
17 html = """
18 <a href="abs.html" title="abs"><tt>abs()</tt></a> (int) <br>
19 <a href="complex/abs.html" title="abs"><tt>abs&lt;&gt;()</tt></a> (std::complex) <br>
20 <a href="acos.html" title="acos"><tt>acos()</tt></a> <br>
21 <a href="acosh.html" title="acosh"><tt>acosh()</tt></a> <span class="t-mark-rev">(since C++11)</span> <br>
22 <a href="as_bytes.html" title="as bytes"><tt>as_bytes&lt;&gt;()</tt></a> <span class="t-mark-rev t-since-cxx20">(since C++20)</span> <br>
23 """
25 actual = _ParseIndexPage(html)
26 expected = [
27 ("abs", "abs.html", "int"),
28 ("abs", "complex/abs.html", "std::complex"),
29 ("acos", "acos.html", None),
30 ("acosh", "acosh.html", None),
31 ("as_bytes", "as_bytes.html", None),
33 self.assertEqual(len(actual), len(expected))
34 for i in range(0, len(actual)):
35 self.assertEqual(expected[i][0], actual[i][0])
36 self.assertTrue(actual[i][1].endswith(expected[i][1]))
37 self.assertEqual(expected[i][2], actual[i][2])
39 def testParseSymbolPage_SingleHeader(self):
40 # Defined in header <cmath>
41 html = """
42 <table class="t-dcl-begin"><tbody>
43 <tr class="t-dsc-header">
44 <td> <div>Defined in header <code><a href="cmath.html" title="cmath">&lt;cmath&gt;</a></code>
45 </div></td>
46 <td></td>
47 <td></td>
48 </tr>
49 <tr class="t-dcl">
50 <td>void foo()</td>
51 <td>this is matched</td>
52 </tr>
53 </tbody></table>
54 """
55 self.assertEqual(_ParseSymbolPage(html, "foo"), set(["<cmath>"]))
57 def testParseSymbolPage_MulHeaders(self):
58 # Defined in header <cstddef>
59 # Defined in header <cstdio>
60 # Defined in header <cstdlib>
61 html = """
62 <table class="t-dcl-begin"><tbody>
63 <tr class="t-dsc-header">
64 <td> <div>Defined in header <code><a href="cstddef.html" title="cstddef">&lt;cstddef&gt;</a></code>
65 </div></td>
66 <td></td>
67 <td></td>
68 </tr>
69 <tr class="t-dcl">
70 <td>void bar()</td>
71 <td>this mentions foo, but isn't matched</td>
72 </tr>
73 <tr class="t-dsc-header">
74 <td> <div>Defined in header <code><a href="cstdio.html" title="cstdio">&lt;cstdio&gt;</a></code>
75 </div></td>
76 <td></td>
77 <td></td>
78 </tr>
79 <tr class="t-dsc-header">
80 <td> <div>Defined in header <code><a href=".cstdlib.html" title="ccstdlib">&lt;cstdlib&gt;</a></code>
81 </div></td>
82 <td></td>
83 <td></td>
84 </tr>
85 <tr class="t-dcl">
86 <td>
87 <span>void</span>
88 foo
89 <span>()</span>
90 </td>
91 <td>this is matched</td>
92 </tr>
93 </tbody></table>
94 """
95 self.assertEqual(_ParseSymbolPage(html, "foo"), set(["<cstdio>", "<cstdlib>"]))
97 def testParseSymbolPage_MulHeadersInSameDiv(self):
98 # Multile <code> blocks in a Div.
99 # Defined in header <algorithm>
100 # Defined in header <utility>
101 html = """
102 <table class="t-dcl-begin"><tbody>
103 <tr class="t-dsc-header">
104 <td><div>
105 Defined in header <code><a href="../header/algorithm.html" title="cpp/header/algorithm">&lt;algorithm&gt;</a></code><br>
106 Defined in header <code><a href="../header/utility.html" title="cpp/header/utility">&lt;utility&gt;</a></code>
107 </div></td>
108 <td></td>
109 </tr>
110 <tr class="t-dcl">
111 <td>
112 <span>void</span>
114 <span>()</span>
115 </td>
116 <td>this is matched</td>
117 </tr>
118 </tbody></table>
120 self.assertEqual(
121 _ParseSymbolPage(html, "foo"), set(["<algorithm>", "<utility>"])
124 def testParseSymbolPage_MulSymbolsInSameTd(self):
125 # defined in header <cstdint>
126 # int8_t
127 # int16_t
128 html = """
129 <table class="t-dcl-begin"><tbody>
130 <tr class="t-dsc-header">
131 <td><div>
132 Defined in header <code><a href="cstdint.html" title="cstdint">&lt;cstdint&gt;</a></code><br>
133 </div></td>
134 <td></td>
135 </tr>
136 <tr class="t-dcl">
137 <td>
138 <span>int8_t</span>
139 <span>int16_t</span>
140 </td>
141 <td>this is matched</td>
142 </tr>
143 </tbody></table>
145 self.assertEqual(_ParseSymbolPage(html, "int8_t"), set(["<cstdint>"]))
146 self.assertEqual(_ParseSymbolPage(html, "int16_t"), set(["<cstdint>"]))
149 if __name__ == "__main__":
150 unittest.main()