Browse Source

Code formatting

tags/v1.0.0
Cédric Belin 1 month ago
parent
commit
6cb8af7960
53 changed files with 1225 additions and 2472 deletions
  1. +4
    -3
      .editorconfig
  2. +21
    -21
      .github/workflows/build.yaml
  3. +0
    -1
      .gitignore
  4. +5
    -5
      .vscode/settings.json
  5. +33
    -33
      composer.json
  6. +31
    -31
      etc/mkdocs.yaml
  7. +3
    -3
      etc/terser.json
  8. +40
    -40
      example/index.html
  9. +25
    -25
      example/main.hx
  10. +21
    -21
      example/main.js
  11. +20
    -20
      example/main.php
  12. +9
    -9
      haxelib.json
  13. +1
    -1
      lib/js/index.cjs
  14. +1
    -1
      lib/js/index.d.ts
  15. +2
    -2
      lib/js/index.mjs
  16. +0
    -148
      lib/php/lcov/BranchCoverage.php
  17. +0
    -112
      lib/php/lcov/BranchData.php
  18. +0
    -169
      lib/php/lcov/FunctionCoverage.php
  19. +0
    -105
      lib/php/lcov/FunctionData.php
  20. +0
    -50
      lib/php/lcov/LcovException.php
  21. +0
    -148
      lib/php/lcov/LineCoverage.php
  22. +0
    -106
      lib/php/lcov/LineData.php
  23. +0
    -139
      lib/php/lcov/Record.php
  24. +0
    -268
      lib/php/lcov/Report.php
  25. +43
    -43
      package.json
  26. +3
    -3
      readthedocs.yaml
  27. +43
    -43
      src/lcov/BranchCoverage.hx
  28. +48
    -48
      src/lcov/BranchData.hx
  29. +45
    -45
      src/lcov/FunctionCoverage.hx
  30. +43
    -43
      src/lcov/FunctionData.hx
  31. +22
    -26
      src/lcov/LcovException.hx
  32. +43
    -43
      src/lcov/LineCoverage.hx
  33. +42
    -42
      src/lcov/LineData.hx
  34. +59
    -57
      src/lcov/Record.hx
  35. +116
    -116
      src/lcov/Report.hx
  36. +26
    -26
      src/lcov/Token.hx
  37. +1
    -1
      src/lcov/import.hx
  38. +2
    -2
      src/php/JsonSerializable.hx
  39. +1
    -1
      src/php/UnexpectedValueException.hx
  40. +13
    -13
      test/Main.hx
  41. +52
    -52
      test/lcov/BranchCoverageTest.hx
  42. +43
    -43
      test/lcov/BranchDataTest.hx
  43. +53
    -53
      test/lcov/FunctionCoverageTest.hx
  44. +47
    -47
      test/lcov/FunctionDataTest.hx
  45. +52
    -52
      test/lcov/LineCoverageTest.hx
  46. +38
    -38
      test/lcov/LineDataTest.hx
  47. +53
    -53
      test/lcov/RecordTest.hx
  48. +92
    -92
      test/lcov/ReportTest.hx
  49. +1
    -1
      tool/clean.ps1
  50. +2
    -2
      tool/dist.ps1
  51. +10
    -10
      tool/doc.ps1
  52. +8
    -8
      tool/version.ps1
  53. +8
    -8
      tool/watch.ps1

+ 4
- 3
.editorconfig View File

@@ -3,11 +3,12 @@ root = true

[*]
charset = utf-8
indent_size = 2
indent_style = space
indent_style = tab
insert_final_newline = true
max_line_length = 200
quote_type = double
tab_width = 2
trim_trailing_whitespace = true

[*.md]
indent_size = 4
trim_trailing_whitespace = false

+ 21
- 21
.github/workflows/build.yaml View File

@@ -1,24 +1,24 @@
name: build
on:
pull_request:
push:
schedule:
- cron: '0 0 1 * *'
pull_request:
push:
schedule:
- cron: "0 0 1 * *"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Set up Haxe
uses: krdlab/setup-haxe@v1
with:
haxe-version: 4.0.5
- name: Check environment
run: |
haxe --version
haxelib version
- name: Fetch sources
uses: actions/checkout@v2
- name: Install dependencies
run: haxelib install all --always
- name: Run tests
run: haxe test.hxml
test:
runs-on: ubuntu-latest
steps:
- name: Set up Haxe
uses: krdlab/setup-haxe@v1
with:
haxe-version: 4.1.0
- name: Check environment
run: |
haxe --version
haxelib version
- name: Fetch sources
uses: actions/checkout@v2
- name: Install dependencies
run: haxelib install all --always
- name: Run tests
run: haxe test.hxml

+ 0
- 1
.gitignore View File

@@ -16,4 +16,3 @@
/npm-debug.log
/package-lock.json
/lib/js/lcov.*
/share/*.private.env.json

+ 5
- 5
.vscode/settings.json View File

@@ -1,7 +1,7 @@
{
"editor.insertSpaces": true,
"editor.tabSize": 2,
"files.encoding": "utf8",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true
"editor.insertSpaces": false,
"editor.tabSize": 2,
"files.encoding": "utf8",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true
}

+ 33
- 33
composer.json View File

@@ -1,35 +1,35 @@
{
"description": "Parse and format to LCOV your code coverage reports. The best way to share your code coverage stats.",
"homepage": "https://docs.belin.io/lcov.hx",
"license": "MIT",
"name": "cedx/lcov.hx",
"type": "library",
"authors": [
{"email": "cedric@belin.io", "homepage": "https://belin.io", "name": "Cédric Belin"}
],
"autoload": {
"psr-4": {"lcov\\": "lib/php/lcov/"}
},
"config": {
"optimize-autoloader": true
},
"funding": [
{"type": "patreon", "url": "https://www.patreon.com/cedx"}
],
"keywords": [
"coverage",
"formatter",
"lcov",
"parser",
"test"
],
"require": {
"php": ">=7.0.0",
"ext-json": "*",
"cedx/haxe": "^0.1.2"
},
"support": {
"docs": "https://api.belin.io/lcov.hx",
"issues": "https://git.belin.io/cedx/lcov.hx/issues"
}
"description": "Parse and format to LCOV your code coverage reports. The best way to share your code coverage stats.",
"homepage": "https://docs.belin.io/lcov.hx",
"license": "MIT",
"name": "cedx/lcov.hx",
"type": "library",
"authors": [
{"email": "cedric@belin.io", "homepage": "https://belin.io", "name": "Cédric Belin"}
],
"autoload": {
"psr-4": {"lcov\\": "lib/php/lcov/"}
},
"config": {
"optimize-autoloader": true
},
"funding": [
{"type": "patreon", "url": "https://www.patreon.com/cedx"}
],
"keywords": [
"coverage",
"formatter",
"lcov",
"parser",
"test"
],
"require": {
"php": ">=7.0.0",
"ext-json": "*",
"cedx/haxe": "^0.1.2"
},
"support": {
"docs": "https://api.belin.io/lcov.hx",
"issues": "https://git.belin.io/cedx/lcov.hx/issues"
}
}

+ 31
- 31
etc/mkdocs.yaml View File

@@ -8,43 +8,43 @@ site_dir: ../www

repo_name: git.belin.io
repo_url: https://git.belin.io/cedx/lcov.hx
edit_uri: ''
edit_uri: ""

copyright: Copyright © 2020 Cédric Belin
extra:
social:
- icon: fontawesome/solid/globe
link: 'https://belin.io'
- icon: fontawesome/brands/github
link: 'https://github.com/cedx'
- icon: fontawesome/brands/twitter
link: 'https://twitter.com/cedxbelin'
- icon: fontawesome/brands/linkedin
link: 'https://linkedin.com/in/cedxbelin'
social:
- icon: fontawesome/solid/globe
link: "https://belin.io"
- icon: fontawesome/brands/github
link: "https://github.com/cedx"
- icon: fontawesome/brands/twitter
link: "https://twitter.com/cedxbelin"
- icon: fontawesome/brands/linkedin
link: "https://linkedin.com/in/cedxbelin"

markdown_extensions:
- admonition
- codehilite
- meta
- toc:
permalink: true
- admonition
- codehilite
- meta
- toc:
permalink: true

nav:
- Overview: index.md
- Installation: installation.md
- Usage: usage.md
- About:
- License: about/license.md
- See also: about/see_also.md
- Overview: index.md
- Installation: installation.md
- Usage: usage.md
- About:
- License: about/license.md
- See also: about/see_also.md

theme:
favicon: img/favicon.ico
features:
- instant
icon:
logo: fontawesome/solid/book-reader
repo: fontawesome/brands/git-alt
name: material
palette:
accent: amber
primary: amber
favicon: img/favicon.ico
features:
- instant
icon:
logo: fontawesome/solid/book-reader
repo: fontawesome/brands/git-alt
name: material
palette:
accent: amber
primary: amber

+ 3
- 3
etc/terser.json View File

@@ -1,5 +1,5 @@
{
"compress": true,
"ecma": 2020,
"mangle": true
"compress": true,
"ecma": 2020,
"mangle": true
}

+ 40
- 40
example/index.html View File

@@ -1,34 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>LCOV for JS</title>
<script src="https://cdn.jsdelivr.net/npm/@cedx/lcov.hx/build/lcov.min.js"></script>
</head>
<body>
<p>Open the console provided by the development tools of your browser...</p>
<script>
// Import the classes.
const {FunctionCoverage, LineCoverage, LineData, Record, Report} = window.lcov;
// Format coverage data as LCOV report.
const lineCoverage = new LineCoverage(2, 2, [
new LineData(6, 2, 'PF4Rz2r7RTliO9u6bZ7h6g'),
new LineData(7, 2, 'yGMB6FhEEAd8OyASe3Ni1w')
]);
const record = new Record('/home/cedx/lcov.hx/fixture.hx', {
functions: new FunctionCoverage(1, 1),
lines: lineCoverage
});
const report = new Report('Example', [record]);
console.log(report.toString());
// Parse a LCOV report to coverage data.
const coverage = `
<head>
<meta charset="UTF-8">
<title>LCOV for JS</title>
<script src="https://cdn.jsdelivr.net/npm/@cedx/lcov.hx/build/lcov.min.js"></script>
</head>
<body>
<p>Open the console provided by the development tools of your browser...</p>
<script>
// Import the classes.
const {FunctionCoverage, LineCoverage, LineData, Record, Report} = window.lcov;
// Format coverage data as LCOV report.
const lineCoverage = new LineCoverage(2, 2, [
new LineData(6, 2, "PF4Rz2r7RTliO9u6bZ7h6g"),
new LineData(7, 2, "yGMB6FhEEAd8OyASe3Ni1w")
]);
const record = new Record("/home/cedx/lcov.hx/fixture.hx", {
functions: new FunctionCoverage(1, 1),
lines: lineCoverage
});
const report = new Report("Example", [record]);
console.log(report.toString());
// Parse a LCOV report to coverage data.
const coverage = `
TN:Example
SF:/home/cedx/lcov.hx/fixture.hx
FN:4,main
@@ -43,15 +43,15 @@ LF:4
LH:4
end_of_record`;

try {
const report = Report.fromCoverage(coverage);
console.log(`The coverage report contains ${report.records.length} record(s):`);
console.log(JSON.stringify(report, null, 2));
}
catch (error) {
console.log(`An error occurred: "${error.message}" at offset ${error.offset}.`);
}
</script>
</body>
try {
const report = Report.fromCoverage(coverage);
console.log(`The coverage report contains ${report.records.length} record(s):`);
console.log(JSON.stringify(report, null, 2));
}
catch (error) {
console.log(`An error occurred: "${error.message}" at offset ${error.offset}.`);
}
</script>
</body>
</html>

+ 25
- 25
example/main.hx View File

@@ -5,33 +5,33 @@ import sys.io.File;
/** A sample class. **/
class Example {

/** Formats coverage data as LCOV report. **/
public function formatReport(): Void {
final lineCoverage = new LineCoverage(2, 2, [
new LineData(6, 2, 'PF4Rz2r7RTliO9u6bZ7h6g'),
new LineData(7, 2, 'yGMB6FhEEAd8OyASe3Ni1w')
]);
/** Formats coverage data as LCOV report. **/
public function formatReport(): Void {
final lineCoverage = new LineCoverage(2, 2, [
new LineData(6, 2, "PF4Rz2r7RTliO9u6bZ7h6g"),
new LineData(7, 2, "yGMB6FhEEAd8OyASe3Ni1w")
]);

final record = new Record('/home/cedx/lcov.hx/fixture.hx', {
functions: new FunctionCoverage(1, 1),
lines: lineCoverage
});
final record = new Record("/home/cedx/lcov.hx/fixture.hx", {
functions: new FunctionCoverage(1, 1),
lines: lineCoverage
});

final report = new Report('Example', [record]);
trace(report.toString());
}
final report = new Report("Example", [record]);
trace(report.toString());
}

/** Parses a LCOV report to coverage data. **/
public function parseReport(): Void {
try {
final coverage = File.getContent('/path/to/lcov.info');
final report = Report.fromCoverage(coverage);
Sys.println('The coverage report contains ${report.records.length} records:');
Sys.println(Json.stringify(report.toJson(), null, ' '));
}
/** Parses a LCOV report to coverage data. **/
public function parseReport(): Void {
try {
final coverage = File.getContent("/path/to/lcov.info");
final report = Report.fromCoverage(coverage);
Sys.println('The coverage report contains ${report.records.length} records:');
Sys.println(Json.stringify(report.toJson(), null, " "));
}

catch (error: LcovException) {
Sys.println('An error occurred: "${error.message}" at offset ${error.offset}.');
}
}
catch (error: LcovException) {
Sys.println('An error occurred: "${error.message}" at offset ${error.offset}.');
}
}
}

+ 21
- 21
example/main.js View File

@@ -1,32 +1,32 @@
import {FunctionCoverage, LineCoverage, LineData, Record, Report} from '@cedx/lcov.hx';
import {promises} from 'fs';
import {FunctionCoverage, LineCoverage, LineData, Record, Report} from "@cedx/lcov.hx";
import {promises} from "fs";

/** Formats coverage data as LCOV report. */
function formatReport() {
const lineCoverage = new LineCoverage(2, 2, [
new LineData(6, 2, 'PF4Rz2r7RTliO9u6bZ7h6g'),
new LineData(7, 2, 'yGMB6FhEEAd8OyASe3Ni1w')
]);
const lineCoverage = new LineCoverage(2, 2, [
new LineData(6, 2, "PF4Rz2r7RTliO9u6bZ7h6g"),
new LineData(7, 2, "yGMB6FhEEAd8OyASe3Ni1w")
]);

const record = new Record('/home/cedx/lcov.hx/fixture.js', {
functions: new FunctionCoverage(1, 1),
lines: lineCoverage
});
const record = new Record("/home/cedx/lcov.hx/fixture.js", {
functions: new FunctionCoverage(1, 1),
lines: lineCoverage
});

const report = new Report('Example', [record]);
console.log(report.toString());
const report = new Report("Example", [record]);
console.log(report.toString());
}

/** Parses a LCOV report to coverage data. */
async function parseReport() {
try {
const coverage = await promises.readFile('/path/to/lcov.info', 'utf8');
const report = Report.fromCoverage(coverage);
console.log(`The coverage report contains ${report.records.length} records:`);
console.log(JSON.stringify(report, null, 2));
}
try {
const coverage = await promises.readFile("/path/to/lcov.info", "utf8");
const report = Report.fromCoverage(coverage);
console.log(`The coverage report contains ${report.records.length} records:`);
console.log(JSON.stringify(report, null, 2));
}

catch (error) {
console.log(`An error occurred: "${error.message}" at offset ${error.offset}.`);
}
catch (error) {
console.log(`An error occurred: "${error.message}" at offset ${error.offset}.`);
}
}

+ 20
- 20
example/main.php View File

@@ -3,32 +3,32 @@ use lcov\{FunctionCoverage, LcovException, LineCoverage, LineData, Record, Repor

/** Formats coverage data as LCOV report. */
function formatReport(): void {
$lineCoverage = new LineCoverage(2, 2, [
new LineData(6, 2, 'PF4Rz2r7RTliO9u6bZ7h6g'),
new LineData(7, 2, 'yGMB6FhEEAd8OyASe3Ni1w')
]);
$lineCoverage = new LineCoverage(2, 2, [
new LineData(6, 2, "PF4Rz2r7RTliO9u6bZ7h6g"),
new LineData(7, 2, "yGMB6FhEEAd8OyASe3Ni1w")
]);

$record = new Record('/home/cedx/lcov.hx/fixture.php', (object) [
'functions' => new FunctionCoverage(1, 1),
'lines' => $lineCoverage
]);
$record = new Record("/home/cedx/lcov.hx/fixture.php", (object) [
"functions" => new FunctionCoverage(1, 1),
"lines" => $lineCoverage
]);

$report = new Report('Example', [$record]);
echo $report;
$report = new Report("Example", [$record]);
echo $report;
}

/** Parses a LCOV report to coverage data. */
function parseReport(): void {
try {
$coverage = file_get_contents('/path/to/lcov.info');
$report = Report::fromCoverage($coverage);
try {
$coverage = file_get_contents("/path/to/lcov.info");
$report = Report::fromCoverage($coverage);

$count = count($report->records);
echo "The coverage report contains $count records:", PHP_EOL;
echo json_encode($report, JSON_PRETTY_PRINT);
}
$count = count($report->records);
echo "The coverage report contains $count records:", PHP_EOL;
echo json_encode($report, JSON_PRETTY_PRINT);
}

catch (LcovException $e) {
echo 'An error occurred: "', $e->getMessage(), '" at offset ', $e->offset, '.';
}
catch (LcovException $e) {
echo "An error occurred: '", $e->getMessage(), "' at offset ", $e->offset, ".";
}
}

+ 9
- 9
haxelib.json View File

@@ -1,11 +1,11 @@
{
"classPath": "src/",
"contributors": ["cedx"],
"description": "Parse and format to LCOV your code coverage reports. The best way to share your code coverage stats.",
"license": "MIT",
"name": "lcov",
"releasenote": "Initial release.",
"tags": ["coverage", "formatter", "lcov", "parser", "test"],
"url": "https://docs.belin.io/lcov.hx",
"version": "0.1.0"
"classPath": "src/",
"contributors": ["cedx"],
"description": "Parse and format to LCOV your code coverage reports. The best way to share your code coverage stats.",
"license": "MIT",
"name": "lcov",
"releasenote": "Initial release.",
"tags": ["coverage", "formatter", "lcov", "parser", "test"],
"url": "https://docs.belin.io/lcov.hx",
"version": "0.1.0"
}

+ 1
- 1
lib/js/index.cjs View File

@@ -1,2 +1,2 @@
const mod = require('./lcov.cjs');
const mod = require("./lcov.cjs");
module.exports = mod.lcov;

+ 1
- 1
lib/js/index.d.ts View File

@@ -1,6 +1,6 @@
/** Defines the shape of a JSON value. */
export declare type Json = null | boolean | number | string | Json[] | {
[property: string]: Json;
[property: string]: Json;
};

/** Defines the shape of an object in JSON format. */


+ 2
- 2
lib/js/index.mjs View File

@@ -1,11 +1,11 @@
import mod from './lcov.cjs';
import mod from "./lcov.cjs";

export const {
BranchCoverage,
BranchData,
FunctionCoverage,
FunctionData,
LcovException,
LcovException,
LineCoverage,
LineData,
Record,


+ 0
- 148
lib/php/lcov/BranchCoverage.php View File

@@ -1,148 +0,0 @@
<?php
/**
* Generated by Haxe 4.0.5
*/

namespace lcov;

use \php\_Boot\HxAnon;
use \php\Boot;

/**
* Provides the coverage data of branches.
*/
class BranchCoverage implements \JsonSerializable {
/**
* @var \Array_hx
* The coverage data.
*/
public $data;
/**
* @var int
* The number of branches found.
*/
public $found;
/**
* @var int
* The number of branches hit.
*/
public $hit;

/**
* Creates a new branch coverage from the specified `map` in JSON format.
*
* @param mixed $map
*
* @return BranchCoverage
*/
public static function fromJson ($map) {
$tmp = (Boot::is(\Reflect::field($map, "found"), Boot::getClass('Int')) ? \Reflect::field($map, "found") : 0);
$tmp1 = (Boot::is(\Reflect::field($map, "hit"), Boot::getClass('Int')) ? \Reflect::field($map, "hit") : 0);
$tmp2 = null;
if ((\Reflect::field($map, "data") instanceof \Array_hx)) {
$_this = \Reflect::field($map, "data");
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = BranchData::fromJson($item);
}

$tmp2 = \Array_hx::wrap($result)->arr;
} else {
$tmp2 = (new \Array_hx())->arr;
}
return new BranchCoverage($tmp, $tmp1, $tmp2);
}

/**
* Creates a new branch coverage.
*
* @param int $found
* @param int $hit
* @param mixed $data
*
* @return void
*/
public function __construct ($found = 0, $hit = 0, $data = null) {
if ($found === null) {
$found = 0;
}
if ($hit === null) {
$hit = 0;
}
$this->data = ($data !== null ? \Array_hx::wrap($data) : new \Array_hx());
$this->found = $found;
$this->hit = $hit;
}

/**
* An alias for the `toJson()` method.
*
* @return object
*/
public function jsonSerialize () {
return $this->toJson();
}

/**
* Converts this object to a map in JSON format.
*
* @return object
*/
public function toJson () {
$_this = $this->data;
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = $item->toJson();
}

$tmp = \Array_hx::wrap($result)->arr;
return new HxAnon([
"data" => $tmp,
"found" => $this->found,
"hit" => $this->hit,
]);
}

/**
* Returns a string representation of this object.
*
* @return string
*/
public function toString () {
$_this = $this->data;
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = $item->toString();
}

$lines = \Array_hx::wrap($result);
$lines->arr[$lines->length] = "" . ("BRF"??'null') . ":" . ($this->found??'null');
++$lines->length;

$lines->arr[$lines->length] = "" . ("BRH"??'null') . ":" . ($this->hit??'null');
++$lines->length;

return $lines->join("\x0A");
}

public function __toString() {
return $this->toString();
}
}

Boot::registerClass(BranchCoverage::class, 'lcov.BranchCoverage');

+ 0
- 112
lib/php/lcov/BranchData.php View File

@@ -1,112 +0,0 @@
<?php
/**
* Generated by Haxe 4.0.5
*/

namespace lcov;

use \php\_Boot\HxAnon;
use \php\Boot;

/**
* Provides details for branch coverage.
*/
class BranchData implements \JsonSerializable {
/**
* @var int
* The block number.
*/
public $blockNumber;
/**
* @var int
* The branch number.
*/
public $branchNumber;
/**
* @var int
* The line number.
*/
public $lineNumber;
/**
* @var int
* A number indicating how often this branch was taken.
*/
public $taken;

/**
* Creates a new branch data from the specified `map` in JSON format.
*
* @param mixed $map
*
* @return BranchData
*/
public static function fromJson ($map) {
$tmp = (Boot::is(\Reflect::field($map, "lineNumber"), Boot::getClass('Int')) ? \Reflect::field($map, "lineNumber") : 0);
$tmp1 = (Boot::is(\Reflect::field($map, "blockNumber"), Boot::getClass('Int')) ? \Reflect::field($map, "blockNumber") : 0);
$tmp2 = (Boot::is(\Reflect::field($map, "branchNumber"), Boot::getClass('Int')) ? \Reflect::field($map, "branchNumber") : 0);
return new BranchData($tmp, $tmp1, $tmp2, (Boot::is(\Reflect::field($map, "taken"), Boot::getClass('Int')) ? \Reflect::field($map, "taken") : 0));
}

/**
* Creates a new branch data.
*
* @param int $lineNumber
* @param int $blockNumber
* @param int $branchNumber
* @param int $taken
*
* @return void
*/
public function __construct ($lineNumber, $blockNumber, $branchNumber, $taken = 0) {
if ($taken === null) {
$taken = 0;
}
$this->blockNumber = $blockNumber;
$this->branchNumber = $branchNumber;
$this->lineNumber = $lineNumber;
$this->taken = $taken;
}

/**
* An alias for the `toJson()` method.
*
* @return object
*/
public function jsonSerialize () {
return $this->toJson();
}

/**
* Converts this object to a map in JSON format.
*
* @return object
*/
public function toJson () {
return new HxAnon([
"blockNumber" => $this->blockNumber,
"branchNumber" => $this->branchNumber,
"lineNumber" => $this->lineNumber,
"taken" => $this->taken,
]);
}

/**
* Returns a string representation of this object.
*
* @return string
*/
public function toString () {
$value = "" . ("BRDA"??'null') . ":" . ($this->lineNumber??'null') . "," . ($this->blockNumber??'null') . "," . ($this->branchNumber??'null');
if ($this->taken > 0) {
return "" . ($value??'null') . "," . ($this->taken??'null');
} else {
return "" . ($value??'null') . ",-";
}
}

public function __toString() {
return $this->toString();
}
}

Boot::registerClass(BranchData::class, 'lcov.BranchData');

+ 0
- 169
lib/php/lcov/FunctionCoverage.php View File

@@ -1,169 +0,0 @@
<?php
/**
* Generated by Haxe 4.0.5
*/

namespace lcov;

use \php\_Boot\HxAnon;
use \php\Boot;

/**
* Provides the coverage data of functions.
*/
class FunctionCoverage implements \JsonSerializable {
/**
* @var \Array_hx
* The coverage data.
*/
public $data;
/**
* @var int
* The number of functions found.
*/
public $found;
/**
* @var int
* The number of functions hit.
*/
public $hit;

/**
* Creates a new function coverage from the specified `map` in JSON format.
*
* @param mixed $map
*
* @return FunctionCoverage
*/
public static function fromJson ($map) {
$tmp = (Boot::is(\Reflect::field($map, "found"), Boot::getClass('Int')) ? \Reflect::field($map, "found") : 0);
$tmp1 = (Boot::is(\Reflect::field($map, "hit"), Boot::getClass('Int')) ? \Reflect::field($map, "hit") : 0);
$tmp2 = null;
if ((\Reflect::field($map, "data") instanceof \Array_hx)) {
$_this = \Reflect::field($map, "data");
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = FunctionData::fromJson($item);
}

$tmp2 = \Array_hx::wrap($result)->arr;
} else {
$tmp2 = (new \Array_hx())->arr;
}
return new FunctionCoverage($tmp, $tmp1, $tmp2);
}

/**
* Creates a new function coverage.
*
* @param int $found
* @param int $hit
* @param mixed $data
*
* @return void
*/
public function __construct ($found = 0, $hit = 0, $data = null) {
if ($found === null) {
$found = 0;
}
if ($hit === null) {
$hit = 0;
}
$this->data = ($data !== null ? \Array_hx::wrap($data) : new \Array_hx());
$this->found = $found;
$this->hit = $hit;
}

/**
* An alias for the `toJson()` method.
*
* @return object
*/
public function jsonSerialize () {
return $this->toJson();
}

/**
* Converts this object to a map in JSON format.
*
* @return object
*/
public function toJson () {
$_this = $this->data;
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = $item->toJson();
}

$tmp = \Array_hx::wrap($result)->arr;
return new HxAnon([
"data" => $tmp,
"found" => $this->found,
"hit" => $this->hit,
]);
}

/**
* Returns a string representation of this object.
*
* @return string
*/
public function toString () {
$_this = $this->data;
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = $item->toString(true);
}

$lines = \Array_hx::wrap($result);
$_g = 0;
$_this1 = $this->data;
$result1 = [];
$data1 = $_this1->arr;
$_g_current1 = 0;
$_g_length1 = count($data1);
$_g_data1 = $data1;
while ($_g_current1 < $_g_length1) {
$item1 = $_g_data1[$_g_current1++];
$result1[] = $item1->toString(false);
}

$_g1 = \Array_hx::wrap($result1);
while ($_g < $_g1->length) {
$line = ($_g1->arr[$_g] ?? null);
++$_g;
$lines->arr[$lines->length] = $line;
++$lines->length;

}

$lines->arr[$lines->length] = "" . ("FNF"??'null') . ":" . ($this->found??'null');
++$lines->length;

$lines->arr[$lines->length] = "" . ("FNH"??'null') . ":" . ($this->hit??'null');
++$lines->length;

return $lines->join("\x0A");
}

public function __toString() {
return $this->toString();
}
}

Boot::registerClass(FunctionCoverage::class, 'lcov.FunctionCoverage');

+ 0
- 105
lib/php/lcov/FunctionData.php View File

@@ -1,105 +0,0 @@
<?php
/**
* Generated by Haxe 4.0.5
*/

namespace lcov;

use \php\_Boot\HxAnon;
use \php\Boot;

/**
* Provides details for function coverage.
*/
class FunctionData implements \JsonSerializable {
/**
* @var int
* The execution count.
*/
public $executionCount;
/**
* @var string
* The function name.
*/
public $functionName;
/**
* @var int
* The line number of the function start.
*/
public $lineNumber;

/**
* Creates a new function data from the specified `map` in JSON format.
*
* @param mixed $map
*
* @return FunctionData
*/
public static function fromJson ($map) {
$tmp = (Boot::is(\Reflect::field($map, "functionName"), Boot::getClass('String')) ? \Reflect::field($map, "functionName") : "");
$tmp1 = (Boot::is(\Reflect::field($map, "lineNumber"), Boot::getClass('Int')) ? \Reflect::field($map, "lineNumber") : 0);
return new FunctionData($tmp, $tmp1, (Boot::is(\Reflect::field($map, "executionCount"), Boot::getClass('Int')) ? \Reflect::field($map, "executionCount") : 0));
}

/**
* Creates a new function data.
*
* @param string $functionName
* @param int $lineNumber
* @param int $executionCount
*
* @return void
*/
public function __construct ($functionName, $lineNumber, $executionCount = 0) {
if ($executionCount === null) {
$executionCount = 0;
}
$this->executionCount = $executionCount;
$this->functionName = $functionName;
$this->lineNumber = $lineNumber;
}

/**
* An alias for the `toJson()` method.
*
* @return object
*/
public function jsonSerialize () {
return $this->toJson();
}

/**
* Converts this object to a map in JSON format.
*
* @return object
*/
public function toJson () {
return new HxAnon([
"executionCount" => $this->executionCount,
"functionName" => $this->functionName,
"lineNumber" => $this->lineNumber,
]);
}

/**
* Returns a string representation of this object.
*
* @param bool $asDefinition
*
* @return string
*/
public function toString ($asDefinition = false) {
if ($asDefinition === null) {
$asDefinition = false;
}
$token = ($asDefinition ? "FN" : "FNDA");
$count = ($asDefinition ? $this->lineNumber : $this->executionCount);
return "" . ($token??'null') . ":" . ($count??'null') . "," . ($this->functionName??'null');
}

public function __toString() {
return $this->toString();
}
}

Boot::registerClass(FunctionData::class, 'lcov.FunctionData');

+ 0
- 50
lib/php/lcov/LcovException.php View File

@@ -1,50 +0,0 @@
<?php
/**
* Generated by Haxe 4.0.5
*/

namespace lcov;

use \php\Boot;

/**
* An exception caused by a parsing error.
*/
class LcovException extends \UnexpectedValueException {
/**
* @var int
* The offset in `source` where the error was detected.
*/
public $offset;
/**
* @var string
* The actual source input which caused the error.
*/
public $source;

/**
* Creates a new LCOV exception.
*
* @param string $message
* @param string $source
* @param int $offset
*
* @return void
*/
public function __construct ($message = "", $source = "", $offset = 0) {
if ($message === null) {
$message = "";
}
if ($source === null) {
$source = "";
}
if ($offset === null) {
$offset = 0;
}
parent::__construct($message);
$this->offset = $offset;
$this->source = $source;
}
}

Boot::registerClass(LcovException::class, 'lcov.LcovException');

+ 0
- 148
lib/php/lcov/LineCoverage.php View File

@@ -1,148 +0,0 @@
<?php
/**
* Generated by Haxe 4.0.5
*/

namespace lcov;

use \php\_Boot\HxAnon;
use \php\Boot;

/**
* Provides the coverage data of lines.
*/
class LineCoverage implements \JsonSerializable {
/**
* @var \Array_hx
* The coverage data.
*/
public $data;
/**
* @var int
* The number of lines found.
*/
public $found;
/**
* @var int
* The number of lines hit.
*/
public $hit;

/**
* Creates a new line coverage from the specified `map` in JSON format.
*
* @param mixed $map
*
* @return LineCoverage
*/
public static function fromJson ($map) {
$tmp = (Boot::is(\Reflect::field($map, "found"), Boot::getClass('Int')) ? \Reflect::field($map, "found") : 0);
$tmp1 = (Boot::is(\Reflect::field($map, "hit"), Boot::getClass('Int')) ? \Reflect::field($map, "hit") : 0);
$tmp2 = null;
if ((\Reflect::field($map, "data") instanceof \Array_hx)) {
$_this = \Reflect::field($map, "data");
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = LineData::fromJson($item);
}

$tmp2 = \Array_hx::wrap($result)->arr;
} else {
$tmp2 = (new \Array_hx())->arr;
}
return new LineCoverage($tmp, $tmp1, $tmp2);
}

/**
* Creates a new line coverage.
*
* @param int $found
* @param int $hit
* @param mixed $data
*
* @return void
*/
public function __construct ($found = 0, $hit = 0, $data = null) {
if ($found === null) {
$found = 0;
}
if ($hit === null) {
$hit = 0;
}
$this->data = ($data !== null ? \Array_hx::wrap($data) : new \Array_hx());
$this->found = $found;
$this->hit = $hit;
}

/**
* An alias for the `toJson()` method.
*
* @return object
*/
public function jsonSerialize () {
return $this->toJson();
}

/**
* Converts this object to a map in JSON format.
*
* @return object
*/
public function toJson () {
$_this = $this->data;
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = $item->toJson();
}

$tmp = \Array_hx::wrap($result)->arr;
return new HxAnon([
"data" => $tmp,
"found" => $this->found,
"hit" => $this->hit,
]);
}

/**
* Returns a string representation of this object.
*
* @return string
*/
public function toString () {
$_this = $this->data;
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = $item->toString();
}

$lines = \Array_hx::wrap($result);
$lines->arr[$lines->length] = "" . ("LF"??'null') . ":" . ($this->found??'null');
++$lines->length;

$lines->arr[$lines->length] = "" . ("LH"??'null') . ":" . ($this->hit??'null');
++$lines->length;

return $lines->join("\x0A");
}

public function __toString() {
return $this->toString();
}
}

Boot::registerClass(LineCoverage::class, 'lcov.LineCoverage');

+ 0
- 106
lib/php/lcov/LineData.php View File

@@ -1,106 +0,0 @@
<?php
/**
* Generated by Haxe 4.0.5
*/

namespace lcov;

use \php\_Boot\HxAnon;
use \php\Boot;

/**
* Provides details for line coverage.
*/
class LineData implements \JsonSerializable {
/**
* @var string
* The data checksum.
*/
public $checksum;
/**
* @var int
* The execution count.
*/
public $executionCount;
/**
* @var int
* The line number.
*/
public $lineNumber;

/**
* Creates a new line data from the specified `map` in JSON format.
*
* @param mixed $map
*
* @return LineData
*/
public static function fromJson ($map) {
$tmp = (Boot::is(\Reflect::field($map, "lineNumber"), Boot::getClass('Int')) ? \Reflect::field($map, "lineNumber") : 0);
$tmp1 = (Boot::is(\Reflect::field($map, "executionCount"), Boot::getClass('Int')) ? \Reflect::field($map, "executionCount") : 0);
return new LineData($tmp, $tmp1, (Boot::is(\Reflect::field($map, "checksum"), Boot::getClass('String')) ? \Reflect::field($map, "checksum") : ""));
}

/**
* Creates a new line data.
*
* @param int $lineNumber
* @param int $executionCount
* @param string $checksum
*
* @return void
*/
public function __construct ($lineNumber, $executionCount = 0, $checksum = "") {
if ($executionCount === null) {
$executionCount = 0;
}
if ($checksum === null) {
$checksum = "";
}
$this->checksum = $checksum;
$this->executionCount = $executionCount;
$this->lineNumber = $lineNumber;
}

/**
* An alias for the `toJson()` method.
*
* @return object
*/
public function jsonSerialize () {
return $this->toJson();
}

/**
* Converts this object to a map in JSON format.
*
* @return object
*/
public function toJson () {
return new HxAnon([
"checksum" => $this->checksum,
"executionCount" => $this->executionCount,
"lineNumber" => $this->lineNumber,
]);
}

/**
* Returns a string representation of this object.
*
* @return string
*/
public function toString () {
$value = "" . ("DA"??'null') . ":" . ($this->lineNumber??'null') . "," . ($this->executionCount??'null');
if (mb_strlen($this->checksum) > 0) {
return "" . ($value??'null') . "," . ($this->checksum??'null');
} else {
return $value;
}
}

public function __toString() {
return $this->toString();
}
}

Boot::registerClass(LineData::class, 'lcov.LineData');

+ 0
- 139
lib/php/lcov/Record.php View File

@@ -1,139 +0,0 @@
<?php
/**
* Generated by Haxe 4.0.5
*/

namespace lcov;

use \php\_Boot\HxAnon;
use \php\Boot;

/**
* Provides the coverage data of a source file.
*/
class Record implements \JsonSerializable {
/**
* @var BranchCoverage
* The branch coverage.
*/
public $branches;
/**
* @var FunctionCoverage
* The function coverage.
*/
public $functions;
/**
* @var LineCoverage
* The line coverage.
*/
public $lines;
/**
* @var string
* The path to the source file.
*/
public $sourceFile;

/**
* Creates a new record from the specified `map` in JSON format.
*
* @param mixed $map
*
* @return Record
*/
public static function fromJson ($map) {
$tmp = (Boot::is(\Reflect::field($map, "sourceFile"), Boot::getClass('String')) ? \Reflect::field($map, "sourceFile") : "");
$tmp1 = (\Reflect::isObject(\Reflect::field($map, "branches")) ? BranchCoverage::fromJson(\Reflect::field($map, "branches")) : null);
$tmp2 = (\Reflect::isObject(\Reflect::field($map, "functions")) ? FunctionCoverage::fromJson(\Reflect::field($map, "functions")) : null);
return new Record($tmp, [
"branches" => $tmp1,
"functions" => $tmp2,
"lines" => (\Reflect::isObject(\Reflect::field($map, "lines")) ? LineCoverage::fromJson(\Reflect::field($map, "lines")) : null),
]);
}

/**
* Creates a new record with the specified source file.
*
* @param string $sourceFile
* @param mixed $options
*
* @return void
*/
public function __construct ($sourceFile, $options = null) {
$this->lines = null;
$this->functions = null;
$this->branches = null;
$this->sourceFile = $sourceFile;
if ($options !== null) {
if (isset($options["branches"])) {
$this->branches = $options["branches"];
}
if (isset($options["functions"])) {
$this->functions = $options["functions"];
}
if (isset($options["lines"])) {
$this->lines = $options["lines"];
}
}
}

/**
* An alias for the `toJson()` method.
*
* @return object
*/
public function jsonSerialize () {
return $this->toJson();
}

/**
* Converts this object to a map in JSON format.
*
* @return object
*/
public function toJson () {
$tmp = ($this->branches !== null ? $this->branches->toJson() : null);
$tmp1 = ($this->functions !== null ? $this->functions->toJson() : null);
$tmp2 = ($this->lines !== null ? $this->lines->toJson() : null);
return new HxAnon([
"branches" => $tmp,
"functions" => $tmp1,
"lines" => $tmp2,
"sourceFile" => $this->sourceFile,
]);
}

/**
* Returns a string representation of this object.
*
* @return string
*/
public function toString () {
$output = \Array_hx::wrap(["" . ("SF"??'null') . ":" . ($this->sourceFile??'null')]);
if ($this->functions !== null) {
$x = $this->functions->toString();
$output->arr[$output->length] = $x;
++$output->length;
}
if ($this->branches !== null) {
$x1 = $this->branches->toString();
$output->arr[$output->length] = $x1;
++$output->length;
}
if ($this->lines !== null) {
$x2 = $this->lines->toString();
$output->arr[$output->length] = $x2;
++$output->length;
}
$output->arr[$output->length] = "end_of_record";
++$output->length;

return $output->join("\x0A");
}

public function __toString() {
return $this->toString();
}
}

Boot::registerClass(Record::class, 'lcov.Record');

+ 0
- 268
lib/php/lcov/Report.php View File

@@ -1,268 +0,0 @@
<?php
/**
* Generated by Haxe 4.0.5
*/

namespace lcov;

use \php\_Boot\HxAnon;
use \php\Boot;
use \php\_Boot\HxString;
use \php\_Boot\HxException;

/**
* Represents a trace file, that is a coverage report.
*/
class Report implements \JsonSerializable {
/**
* @var \Array_hx
* The record list.
*/
public $records;
/**
* @var string
* The test name.
*/
public $testName;

/**
* Parses the specified `coverage` data in [LCOV](http://ltp.sourceforge.net/coverage/lcov.php) format.
* Throws a `LcovException` if a parsing error occurred.
*
* @param string $coverage
*
* @return Report
*/
public static function fromCoverage ($coverage) {
$report = new Report();
try {
$offset = 0;
$record = null;
$_g = 0;
$_g1 = (new \EReg("\x0D?\x0A", "g"))->split($coverage);
while ($_g < $_g1->length) {
$line = ($_g1->arr[$_g] ?? null);
++$_g;
$offset += mb_strlen($line);
$line = trim($line);
if (mb_strlen($line) === 0) {
continue;
}
$parts = HxString::split($line, ":");
if (($parts->length < 2) && (($parts->arr[0] ?? null) !== "end_of_record")) {
throw new LcovException("Invalid token format.", $coverage, $offset);
}
if ($parts->length > 0) {
$parts->length--;
}
$token = array_shift($parts->arr);
$data = HxString::split($parts->join(":"), ",");
if ($token === "BRDA") {
if ($data->length < 4) {
throw new LcovException("Invalid branch data.", $coverage, $offset);
}
$_this = $record->branches->data;
$x = \Std::parseInt(($data->arr[0] ?? null));
$x1 = \Std::parseInt(($data->arr[1] ?? null));
$x2 = \Std::parseInt(($data->arr[2] ?? null));
$x3 = new BranchData($x, $x1, $x2, (($data->arr[3] ?? null) === "-" ? 0 : \Std::parseInt(($data->arr[3] ?? null))));
$_this->arr[$_this->length] = $x3;
++$_this->length;

} else if ($token === "BRF") {
$record->branches->found = \Std::parseInt(($data->arr[0] ?? null));
} else if ($token === "BRH") {
$record->branches->hit = \Std::parseInt(($data->arr[0] ?? null));
} else if ($token === "DA") {
if ($data->length < 2) {
throw new LcovException("Invalid line data.", $coverage, $offset);
}
$_this1 = $record->lines->data;
$x4 = \Std::parseInt(($data->arr[0] ?? null));
$x5 = \Std::parseInt(($data->arr[1] ?? null));
$x6 = new LineData($x4, $x5, ($data->length >= 3 ? ($data->arr[2] ?? null) : ""));
$_this1->arr[$_this1->length] = $x6;
++$_this1->length;

} else if ($token === "FN") {
if ($data->length < 2) {
throw new LcovException("Invalid function name.", $coverage, $offset);
}
$_this2 = $record->functions->data;
$data1 = ($data->arr[1] ?? null);
$x7 = new FunctionData($data1, \Std::parseInt(($data->arr[0] ?? null)));
$_this2->arr[$_this2->length] = $x7;
++$_this2->length;

} else if ($token === "FNDA") {
if ($data->length < 2) {
throw new LcovException("Invalid function data.", $coverage, $offset);
}
$_g2 = 0;
$_g11 = $record->functions->data;
while ($_g2 < $_g11->length) {
$item = ($_g11->arr[$_g2] ?? null);
++$_g2;
if ($item->functionName === ($data->arr[1] ?? null)) {
$item->executionCount = \Std::parseInt(($data->arr[0] ?? null));
break;
}
}

} else if ($token === "FNF") {
$record->functions->found = \Std::parseInt(($data->arr[0] ?? null));
} else if ($token === "FNH") {
$record->functions->hit = \Std::parseInt(($data->arr[0] ?? null));
} else if ($token === "LF") {
$record->lines->found = \Std::parseInt(($data->arr[0] ?? null));
} else if ($token === "LH") {
$record->lines->hit = \Std::parseInt(($data->arr[0] ?? null));
} else if ($token === "SF") {
$data2 = ($data->arr[0] ?? null);
$record1 = new BranchCoverage();
$record2 = new FunctionCoverage();
$record = new Record($data2, [
"branches" => $record1,
"functions" => $record2,
"lines" => new LineCoverage(),
]);
} else if ($token === "TN") {
$report->testName = ($data->arr[0] ?? null);
} else if ($token === "end_of_record") {
$_this3 = $report->records;
$_this3->arr[$_this3->length] = $record;
++$_this3->length;
}
}

} catch (\Throwable $__hx__caught_e) {
$__hx__real_e = ($__hx__caught_e instanceof HxException ? $__hx__caught_e->e : $__hx__caught_e);
if ($__hx__real_e instanceof LcovException) {
$e = $__hx__real_e;
throw $e;
} else {
$e1 = $__hx__real_e;
throw new LcovException("The coverage data has an invalid LCOV format.", $coverage);
}
}
if ($report->records->length === 0) {
throw new LcovException("The coverage data is empty.", $coverage);
}
return $report;
}

/**
* Creates a new report from the specified `map` in JSON format.
*
* @param mixed $map
*
* @return Report
*/
public static function fromJson ($map) {
$tmp = (Boot::is(\Reflect::field($map, "testName"), Boot::getClass('String')) ? \Reflect::field($map, "testName") : "");
$tmp1 = null;
if ((\Reflect::field($map, "records") instanceof \Array_hx)) {
$_this = \Reflect::field($map, "records");
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = Record::fromJson($item);
}

$tmp1 = \Array_hx::wrap($result)->arr;
} else {
$tmp1 = (new \Array_hx())->arr;
}
return new Report($tmp, $tmp1);
}

/**
* Creates a new report.
*
* @param string $testName
* @param mixed $records
*
* @return void
*/
public function __construct ($testName = "", $records = null) {
if ($testName === null) {
$testName = "";
}
$this->records = ($records !== null ? \Array_hx::wrap($records) : new \Array_hx());
$this->testName = $testName;
}

/**
* An alias for the `toJson()` method.
*
* @return object
*/
public function jsonSerialize () {
return $this->toJson();
}

/**
* Converts this object to a map in JSON format.
*
* @return object
*/
public function toJson () {
$_this = $this->records;
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = $item->toJson();
}

$tmp = \Array_hx::wrap($result)->arr;
return new HxAnon([
"records" => $tmp,
"testName" => $this->testName,
]);
}

/**
* Returns a string representation of this object.
*
* @return string
*/
public function toString () {
$lines = (mb_strlen($this->testName) > 0 ? \Array_hx::wrap(["" . ("TN"??'null') . ":" . ($this->testName??'null')]) : new \Array_hx());
$_g = 0;
$_this = $this->records;
$result = [];
$data = $_this->arr;
$_g_current = 0;
$_g_length = count($data);
$_g_data = $data;
while ($_g_current < $_g_length) {
$item = $_g_data[$_g_current++];
$result[] = $item->toString();
}

$_g1 = \Array_hx::wrap($result);
while ($_g < $_g1->length) {
$record = ($_g1->arr[$_g] ?? null);
++$_g;
$lines->arr[$lines->length] = $record;
++$lines->length;

}

return $lines->join("\x0A");
}

public function __toString() {
return $this->toString();
}
}

Boot::registerClass(Report::class, 'lcov.Report');

+ 43
- 43
package.json View File

@@ -1,45 +1,45 @@
{
"bugs": "https://git.belin.io/cedx/lcov.hx/issues",
"description": "Parse and format to LCOV your code coverage reports. The best way to share your code coverage stats.",
"homepage": "https://docs.belin.io/lcov.hx",
"license": "MIT",
"main": "lib/js/lcov.cjs",
"name": "@cedx/lcov.hx",
"type": "module",
"types": "lib/js/lcov.d.ts",
"version": "0.1.0",
"author": {
"email": "cedric@belin.io",
"name": "Cédric Belin",
"url": "https://belin.io"
},
"devDependencies": {
"terser": "^4.6.13"
},
"engines": {
"node": ">=14.0.0"
},
"exports": {
"import": "lib/js/lcov.mjs",
"require": "lib/js/lcov.cjs"
},
"files": [
"build/",
"lib/js/"
],
"funding": {
"type": "patreon",
"url": "https://www.patreon.com/cedx"
},
"keywords": [
"coverage",
"formatter",
"lcov",
"parser",
"test"
],
"repository": {
"type": "git",
"url": "https://git.belin.io/cedx/lcov.hx.git"
}
"bugs": "https://git.belin.io/cedx/lcov.hx/issues",
"description": "Parse and format to LCOV your code coverage reports. The best way to share your code coverage stats.",
"homepage": "https://docs.belin.io/lcov.hx",
"license": "MIT",
"main": "lib/js/lcov.cjs",
"name": "@cedx/lcov.hx",
"type": "module",
"types": "lib/js/lcov.d.ts",
"version": "0.1.0",
"author": {
"email": "cedric@belin.io",
"name": "Cédric Belin",
"url": "https://belin.io"
},
"devDependencies": {
"terser": "^4.6.13"
},
"engines": {
"node": ">=14.0.0"
},
"exports": {
"import": "lib/js/lcov.mjs",
"require": "lib/js/lcov.cjs"
},
"files": [
"build/",
"lib/js/"
],
"funding": {
"type": "patreon",
"url": "https://www.patreon.com/cedx"
},
"keywords": [
"coverage",
"formatter",
"lcov",
"parser",
"test"
],
"repository": {
"type": "git",
"url": "https://git.belin.io/cedx/lcov.hx.git"
}
}

+ 3
- 3
readthedocs.yaml View File

@@ -1,6 +1,6 @@
version: 2
mkdocs:
configuration: etc/mkdocs.yaml
configuration: etc/mkdocs.yaml
python:
install:
- requirements: etc/requirements.txt
install:
- requirements: etc/requirements.txt

+ 43
- 43
src/lcov/BranchCoverage.hx View File

@@ -4,49 +4,49 @@ package lcov;
@:expose
class BranchCoverage #if php implements JsonSerializable #end {

/** The coverage data. **/
public final data: Array<BranchData>;
/** The number of branches found. **/
public var found: Int;
/** The number of branches hit. **/
public var hit: Int;
/** Creates a new branch coverage. **/
public function new(found: Int = 0, hit: Int = 0, ?data: #if php NativeIndexedArray<BranchData> #else Array<BranchData> #end) {
this.data = data != null ? #if php cast toHaxeArray(data) #else data #end : [];
this.found = found;
this.hit = hit;
}
/** Creates a new branch coverage from the specified `map` in JSON format. **/
public static function fromJson(map: DynamicAccess<Any>) return new BranchCoverage(
Std.is(map['found'], Int) ? map['found'] : 0,
Std.is(map['hit'], Int) ? map['hit'] : 0,
Std.is(map['data'], Array) ? (map['data']: Array<Any>).map(item -> BranchData.fromJson(item)) : []
);
/** Converts this object to a map in JSON format. **/
public function toJson() return {
data: #if php toPhpArray(data.map(item -> item.toJson())) #else data.map(item -> item.toJson()) #end,
found: found,
hit: hit
};
/** Returns a string representation of this object. **/
public function toString(): String {
final lines = data.map(item -> item.toString());
lines.push('${Token.branchesFound}:$found');
lines.push('${Token.branchesHit}:$hit');
return lines.join('\n');
}
#if js
/** An alias for the `toJson()` method. **/
/** The coverage data. **/
public final data: Array<BranchData>;
/** The number of branches found. **/
public var found: Int;
/** The number of branches hit. **/
public var hit: Int;
/** Creates a new branch coverage. **/
public function new(found: Int = 0, hit: Int = 0, ?data: #if php NativeIndexedArray<BranchData> #else Array<BranchData> #end) {
this.data = data != null ? #if php cast toHaxeArray(data) #else data #end : [];
this.found = found;
this.hit = hit;
}
/** Creates a new branch coverage from the specified `map` in JSON format. **/
public static function fromJson(map: DynamicAccess<Any>) return new BranchCoverage(
Std.is(map["found"], Int) ? map["found"] : 0,
Std.is(map["hit"], Int) ? map["hit"] : 0,
Std.is(map["data"], Array) ? (map["data"]: Array<Any>).map(item -> BranchData.fromJson(item)) : []
);
/** Converts this object to a map in JSON format. **/
public function toJson() return {
data: #if php toPhpArray(data.map(item -> item.toJson())) #else data.map(item -> item.toJson()) #end,
found: found,
hit: hit
};
/** Returns a string representation of this object. **/
public function toString(): String {
final lines = data.map(item -> item.toString());
lines.push('${Token.branchesFound}:$found');
lines.push('${Token.branchesHit}:$hit');
return lines.join("\n");
}
#if js
/** An alias for the `toJson()` method. **/
public function toJSON() return toJson();
#elseif php
/** An alias for the `toJson()` method. **/
#elseif php
/** An alias for the `toJson()` method. **/
public function jsonSerialize() return toJson();
#end
#end
}

+ 48
- 48
src/lcov/BranchData.hx View File

@@ -3,54 +3,54 @@ package lcov;
/** Provides details for branch coverage. **/
@:expose
class BranchData #if php implements JsonSerializable #end {
/** The block number. **/
public var blockNumber: Int;
/** The branch number. **/
public var branchNumber: Int;
/** The line number. **/
public var lineNumber: Int;
/** A number indicating how often this branch was taken. **/
public var taken: Int;
/** Creates a new branch data. **/
public function new(lineNumber: Int, blockNumber: Int, branchNumber: Int, taken: Int = 0) {
this.blockNumber = blockNumber;
this.branchNumber = branchNumber;
this.lineNumber = lineNumber;
this.taken = taken;
}
/** Creates a new branch data from the specified `map` in JSON format. **/
public static function fromJson(map: DynamicAccess<Any>) return new BranchData(