Skip to content

Commit 8fa040e

Browse files
committed
Addresses review comments.
1 parent 1167381 commit 8fa040e

File tree

7 files changed

+442
-43
lines changed

7 files changed

+442
-43
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/utils/data/feature_test_macros/test_data.json
2+
# ===----------------------------------------------------------------------===##
3+
#
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
7+
#
8+
# ===----------------------------------------------------------------------===##
9+
10+
import sys
11+
12+
sys.path.append(sys.argv[1])
13+
from generate_feature_test_macro_components import feature_test_macros
14+
15+
16+
def test(output, expected):
17+
assert output == expected, f"expected\n{expected}\n\noutput\n{output}"
18+
19+
20+
fmt = feature_test_macros(sys.argv[2])
21+
test(
22+
fmt.get_dialect_versions(),
23+
{
24+
"__cpp_lib_any": {
25+
"c++17": "201606L",
26+
"c++20": "201606L",
27+
"c++23": "201606L",
28+
"c++26": "201606L",
29+
},
30+
"__cpp_lib_barrier": {
31+
"c++20": "201907L",
32+
"c++23": "201907L",
33+
"c++26": "201907L",
34+
},
35+
"__cpp_lib_format": {
36+
"c++20": None,
37+
"c++23": None,
38+
"c++26": None,
39+
},
40+
"__cpp_lib_parallel_algorithm": {
41+
"c++17": "201603L",
42+
"c++20": "201603L",
43+
"c++23": "201603L",
44+
"c++26": "201603L",
45+
},
46+
"__cpp_lib_variant": {
47+
"c++17": "202102L",
48+
"c++20": "202102L",
49+
"c++23": "202102L",
50+
"c++26": "202102L",
51+
},
52+
},
53+
)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/utils/data/feature_test_macros/test_data.json
2+
# ===----------------------------------------------------------------------===##
3+
#
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
7+
#
8+
# ===----------------------------------------------------------------------===##
9+
10+
import sys
11+
12+
sys.path.append(sys.argv[1])
13+
from generate_feature_test_macro_components import feature_test_macros
14+
15+
16+
def test(output, expected):
17+
assert output == expected, f"expected\n{expected}\n\noutput\n{output}"
18+
19+
20+
fmt = feature_test_macros(sys.argv[2])
21+
test(
22+
fmt.get_std_dialect_versions(),
23+
{
24+
"__cpp_lib_any": {
25+
"c++17": "201606L",
26+
"c++20": "201606L",
27+
"c++23": "201606L",
28+
"c++26": "201606L",
29+
},
30+
"__cpp_lib_barrier": {
31+
"c++20": "201907L",
32+
"c++23": "201907L",
33+
"c++26": "201907L",
34+
},
35+
"__cpp_lib_format": {
36+
"c++20": "202110L",
37+
"c++23": "202207L",
38+
"c++26": "202311L",
39+
},
40+
"__cpp_lib_parallel_algorithm": {
41+
"c++17": "201603L",
42+
"c++20": "201603L",
43+
"c++23": "201603L",
44+
"c++26": "201603L",
45+
},
46+
"__cpp_lib_variant": {
47+
"c++17": "202102L",
48+
"c++20": "202106L",
49+
"c++23": "202106L",
50+
"c++26": "202306L",
51+
},
52+
},
53+
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/utils/data/feature_test_macros/test_data.json
2+
# ===----------------------------------------------------------------------===##
3+
#
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
7+
#
8+
# ===----------------------------------------------------------------------===##
9+
10+
import sys
11+
12+
sys.path.append(sys.argv[1])
13+
from generate_feature_test_macro_components import feature_test_macros
14+
15+
16+
def test(output, expected):
17+
assert output == expected, f"expected\n{expected}\n\noutput\n{output}"
18+
19+
20+
fmt = feature_test_macros(sys.argv[2])
21+
test(
22+
fmt.get_std_dialects(),
23+
[
24+
"c++17",
25+
"c++20",
26+
"c++23",
27+
"c++26",
28+
],
29+
)
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# RUN: %{python} %s %{libcxx-dir}/utils %t
2+
# ===----------------------------------------------------------------------===##
3+
#
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
7+
#
8+
# ===----------------------------------------------------------------------===##
9+
10+
import sys
11+
import json
12+
13+
sys.path.append(sys.argv[1])
14+
from generate_feature_test_macro_components import feature_test_macros
15+
16+
17+
def test(output, expected):
18+
assert output == expected, f"expected\n{expected}\n\noutput\n{output}"
19+
20+
21+
def test_error(data, type, message):
22+
tmp = sys.argv[2]
23+
with open(tmp, "w") as file:
24+
file.write(json.dumps(data))
25+
fmt = feature_test_macros(tmp)
26+
try:
27+
fmt.get_dialect_versions()
28+
except type as error:
29+
test(str(error), message)
30+
else:
31+
assert False, "no exception was thrown"
32+
33+
34+
test_error(
35+
[
36+
{
37+
"values": {
38+
"c++17": {
39+
"197001": [
40+
{
41+
"implemented": False,
42+
},
43+
],
44+
},
45+
},
46+
"headers": [],
47+
},
48+
],
49+
KeyError,
50+
"'name'",
51+
)
52+
53+
test_error(
54+
[
55+
{
56+
"name": "a",
57+
"headers": [],
58+
},
59+
],
60+
KeyError,
61+
"'values'",
62+
)
63+
64+
test_error(
65+
[
66+
{
67+
"name": "a",
68+
"values": {},
69+
"headers": [],
70+
},
71+
],
72+
AssertionError,
73+
"'values' is empty",
74+
)
75+
76+
77+
test_error(
78+
[
79+
{
80+
"name": "a",
81+
"values": {
82+
"c++17": {},
83+
},
84+
"headers": [],
85+
},
86+
],
87+
AssertionError,
88+
"a[c++17] has no entries",
89+
)
90+
91+
test_error(
92+
[
93+
{
94+
"name": "a",
95+
"values": {
96+
"c++17": {
97+
"197001": [
98+
{},
99+
],
100+
},
101+
},
102+
"headers": [],
103+
},
104+
],
105+
KeyError,
106+
"'implemented'",
107+
)

libcxx/test/libcxx/feature_test_macro_csv.sh.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

libcxx/utils/data/feature_test_macros/test_data.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,28 @@
9898
"format"
9999
]
100100
},
101+
{
102+
"name": "__cpp_lib_parallel_algorithm",
103+
"values": {
104+
"c++17": {
105+
"201603": [
106+
{
107+
"implemented": true
108+
}
109+
]
110+
}
111+
},
112+
"headers": [
113+
"algorithm",
114+
"numeric"
115+
]
116+
},
101117
{
102118
"name": "__cpp_lib_variant",
103119
"values": {
104120
"c++17": {
105121
"202102": [
106122
{
107-
"number": "",
108123
"title": "``std::visit`` for classes derived from ``std::variant``",
109124
"implemented": true
110125
}

0 commit comments

Comments
 (0)