chore: add D and SDL syntax samples

This commit is contained in:
winston 2023-10-21 03:38:05 +02:00
parent f5a0ffb859
commit ba66c8aa34
No known key found for this signature in database
GPG key ID: 3786770EDBC2B481
2 changed files with 134 additions and 0 deletions

100
samples/d.d Normal file
View file

@ -0,0 +1,100 @@
/*
* Some block commments
* go here
*/
/+
+ Nesting comment
+/
/// A single line documentation comment
module net.masterthought.cucumber.report_information;
import std.algorithm;
import std.array;
import std.string;
import std.conv : to; // line comment about this import
import jsonizer.tojson;
import net.masterthought.cucumber.report_parser;
/**
* A documentation comment
*/
@safe:
class ReportInformation
{
deprecated string originalId = "Some text\twith a gap";
string runId = `Some \n Text`;
string anotherId = "\¶\U0001F603"; // ¶😃
Feature[] features;
private auto symbol = '£';
private string m_name;
@property string name()
{
return m_name;
}
this(ReportParser parser)
{
this.runId = parser.getRunId();
this.features = parser.getReports().map!(report => report.getFeatures()).joiner.array;
}
private Feature[] processFeatures(Feature[] features)
{
return features.map!((f) {
f.featureInformation = calculateFeatureInformation(f);
f.scenarios = addScenarioInformation(f);
return f;
}).array;
}
public auto getTotalNumberOfBackgroundScenariosUnknown()
{
return features.map!(f => f.getBackgroundScenariosUnknown().length).sum;
}
}
struct
{
string name;
}
union
{
string day;
}
unittest
{
// load test json from file
auto testJson = to!string(read("src/test/resources/project1.json"));
string runId = "run 1";
ReportInformation ri = new ReportInformation(new ReportParser(runId, [
testJson
]));
assert(ri.name != null);
// should have correct number of features
ri.getFeatures().length.assertEqual(2);
// overall status
ri.getOverallStatus.assertEqual(to!string(Status.Failed));
// feature totals
Feature feature = ri.getFeatures().front;
}
T foo(T, E:
Exception)(Node node, in string path)
{
return node.bar!(T, E)(path);
}

34
samples/sdl.sdl Normal file
View file

@ -0,0 +1,34 @@
// This is a node with a single string value
title "Hello, World"
// Multiple values are supported, too
bookmarks 12 15 188 1234
// Nodes can have attributes
author "Peter Parker" email="peter@example.org" active=true
// Nodes can be arbitrarily nested
contents {
section "First section" {
paragraph "This is the first paragraph"
paragraph "This is the second paragraph"
}
}
// Anonymous nodes are supported
"This text is the value of an anonymous node!"
// This makes things like matrix definitions very convenient
matrix {
1 0 0
0 1 0
0 0 1
}
foo 2013/2/22 07:53:34.123-GMT+05:30 bar=null
xml `
<product>
<shoes color="blue"/>
</product>
`