Skip to content

Commit 66ff5b8

Browse files
test(language): cover the .d rule in the shared classifier tests
lang_probe_bytes_follow_the_name, lang_classify_matches_every_content_rule and the unreadable-content test now include .d: a 4 KB probe, a cargo dep-info line that is not indexed and D source that stays D, through both cbm_language_classify and cbm_disambiguate_d. With lang_probe_d disabled, the first two fail, as does discover_d_dep_info_not_indexed_as_dlang. Signed-off-by: Nelson Spence <nelson@projectnavi.ai>
1 parent c461ed0 commit 66ff5b8

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎tests/test_language.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,7 @@ TEST(lang_probe_bytes_follow_the_name) {
14151415
ASSERT_EQ(cbm_language_probe_bytes("foo.inc"), 4096);
14161416
ASSERT_EQ(cbm_language_probe_bytes("Form1.frm"), 4096);
14171417
ASSERT_EQ(cbm_language_probe_bytes("App.res"), 4096);
1418+
ASSERT_EQ(cbm_language_probe_bytes("app.d"), 4096);
14181419
ASSERT_EQ(cbm_language_probe_bytes("Widget.cfc"), 16384);
14191420
ASSERT_EQ(cbm_language_probe_bytes("pom.xml"), 255);
14201421
/* An unknown name falls back to a shebang probe of the first line. */
@@ -1456,6 +1457,9 @@ TEST(lang_classify_matches_every_content_rule) {
14561457
{"p.frm", "#procedure foo\nLocal F = a;\n", CBM_LANG_FORM, cbm_disambiguate_frm},
14571458
{"q.res", "RSRC\0\0\0\1binary", CBM_LANG_COUNT, cbm_disambiguate_res},
14581459
{"r.res", "let x = 1\n", CBM_LANG_RESCRIPT, cbm_disambiguate_res},
1460+
{"dep.d", "target/debug/deps/app-0a1b2c.d: src/main.rs src/lib.rs\n", CBM_LANG_COUNT,
1461+
cbm_disambiguate_d},
1462+
{"app.d", "module app;\nimport std.stdio : writeln;\n", CBM_LANG_DLANG, cbm_disambiguate_d},
14591463
{"s.xml", "<?xml version=\"1.0\"?>\n<Export generator=\"IRIS\" version=\"26\">\n",
14601464
CBM_LANG_OBJECTSCRIPT_EXPORT, NULL},
14611465
{"t.xml", "<?xml version=\"1.0\"?>\n<project/>\n", CBM_LANG_XML, NULL},
@@ -1503,6 +1507,7 @@ TEST(lang_classify_unreadable_content_keeps_the_name_default) {
15031507
ASSERT_EQ(cbm_language_classify("a.cfc", NULL, 0, false, false), CBM_LANG_CFSCRIPT);
15041508
ASSERT_EQ(cbm_language_classify("a.frm", NULL, 0, false, false), CBM_LANG_FORM);
15051509
ASSERT_EQ(cbm_language_classify("a.res", NULL, 0, false, false), CBM_LANG_RESCRIPT);
1510+
ASSERT_EQ(cbm_language_classify("a.d", NULL, 0, false, false), CBM_LANG_DLANG);
15061511
ASSERT_EQ(cbm_language_classify("a.xml", NULL, 0, false, false), CBM_LANG_XML);
15071512
ASSERT_EQ(cbm_language_classify("run-tests", NULL, 0, false, false), CBM_LANG_COUNT);
15081513
ASSERT_EQ(cbm_language_classify("main.go", NULL, 0, false, false), CBM_LANG_GO);

0 commit comments

Comments
 (0)