• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hetalang / heta-compiler / 26298298082

22 May 2026 04:00PM UTC coverage: 73.248% (-0.1%) from 73.345%
26298298082

push

github

metelkin
d-switcher support DynMS

1915 of 2857 branches covered (67.03%)

Branch coverage included in aggregate %.

4 of 13 new or added lines in 1 file covered. (30.77%)

3665 of 4761 relevant lines covered (76.98%)

156.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.49
/src/mrgsolve-export/expression.js
1
const { Expression } = require('../core/expression');
2✔
2

3
Expression.prototype.toCString = function(logger, _mathOptions = {}, substituteByDefinitions = true){
2✔
4
  // set defaults
5
  let mathOptions = Object.assign({
31✔
6
    timeVariable: 'SOLVERTIME'
7
  }, _mathOptions);
8

9
  let tree = substituteByDefinitions ? this.substituteByDefinitions().exprParsed : this.exprParsed;
31!
10

11
  let CStringHandler = (node, options) => {
31✔
12
    // ConstantNode
13
    if (node.type === 'ConstantNode' && Number.isInteger(node.value)) {
130✔
14
      return node.value + '.0';
24✔
15
    }
16

17
    // OperatorNode
18
    if (node.type === 'OperatorNode') {
106✔
19
      if (node.fn === 'and') {
44!
NEW
20
        return node.args
×
NEW
21
          .map((arg) => arg.toString(options))
×
22
          .join(' && ');
23
      }
24
      if (node.fn === 'or') {
44!
NEW
25
        return node.args
×
NEW
26
          .map((arg) => arg.toString(options))
×
27
          .join(' || ');
28
      }
29
      if (node.fn === 'xor') {
44!
NEW
30
        let args = node.args
×
NEW
31
          .map((arg) => arg.toString(options))
×
32
          .join(', ');
NEW
33
        return `xor(${args})`;
×
34
      }
35
      if (node.fn === 'not') {
44!
NEW
36
        let arg0 = node.args[0].toString(options, true);
×
NEW
37
        return `!${arg0}`;
×
38
      }
39
      if (node.fn === 'pow') {
44✔
40
        return `pow(${node.args[0].toString(options)}, ${node.args[1].toString(options)})`;
1✔
41
      }
42
      if (node.fn === 'unaryPlus') {
43✔
43
        return node.args[0].toString(options);
4✔
44
      }
45
    }
46

47
    // FunctionNode
48
    if (node.type === 'FunctionNode') {
101✔
49
      if (node.fn.name === 'abs') {
5✔
50
        return `fabs(${node.args[0].toString(options)})`;
1✔
51
      }
52
      if (node.fn.name === 'max') {
4✔
53
        let args = node.args
1✔
54
          .map((arg) => arg.toString(options))
3✔
55
          .join(', ');
56
        return `std::max(${args})`;
1✔
57
      }
58
      if (node.fn.name === 'min') {
3✔
59
        let args = node.args
1✔
60
          .map((arg) => arg.toString(options))
3✔
61
          .join(', ');
62
        return `std::min(${args})`;
1✔
63
      }
64
      if (node.fn.name === 'piecewise') {
2!
65
        let msg = `mrgsolve format does not support "piecewise" function, got "${node.toString()}"`;
×
66
        logger && logger.error(msg);
×
67
        let args = node.args
×
68
          .map((arg) => arg.toString(options));
×
69
        return `piecewise(${args.join(',')})`;
×
70
      }
71
    }
72

73
    // SymbolNode
74
    if (node.type === 'SymbolNode' && node.name === 't') {
98✔
75
      return mathOptions.timeVariable;
1✔
76
    }
77
  };
78

79
  return tree.toString({
31✔
80
    parenthesis: 'keep',
81
    implicit: 'show',   
82
    handler: CStringHandler
83
  });
84
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc