UNPKG

@gmsoft/spel2js

Version:

Parse Spring Expression Language in JavaScript

285 lines (284 loc) 9.2 kB
<!doctype html> <html lang="en"> <head> <title>Code coverage report for src\ast\OpMultiply.js</title> <meta charset="utf-8" /> <link rel="stylesheet" href="../../prettify.css" /> <link rel="stylesheet" href="../../base.css" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <style type='text/css'> .coverage-summary .sorter { background-image: url(../../sort-arrow-sprite.png); } </style> </head> <body> <div class='wrapper'> <div class='pad1'> <h1> <a href="../../index.html">all files</a> / <a href="index.html">src/ast/</a> OpMultiply.js </h1> <div class='clearfix'> <div class='fl pad1y space-right2'> <span class="strong">64.71% </span> <span class="quiet">Statements</span> <span class='fraction'>11/17</span> </div> <div class='fl pad1y space-right2'> <span class="strong">37.5% </span> <span class="quiet">Branches</span> <span class='fraction'>3/8</span> </div> <div class='fl pad1y space-right2'> <span class="strong">100% </span> <span class="quiet">Functions</span> <span class='fraction'>2/2</span> </div> <div class='fl pad1y space-right2'> <span class="strong">62.5% </span> <span class="quiet">Lines</span> <span class='fraction'>10/16</span> </div> </div> </div> <div class='status-line medium'></div> <pre><table class="coverage"> <tr><td class="line-count quiet">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">/* * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ &nbsp; import { SpelNode } from './SpelNode'; &nbsp; /** * Implements the {@code multiply} operator. * * &lt;p&gt;Conversions and promotions are handled as defined in * &lt;a href="http://java.sun.com/docs/books/jls/third_edition/html/conversions.html"&gt;Section 5.6.2 of the * Java Language Specification&lt;/a&gt;, with the addiction of {@code BigDecimal}/{@code BigInteger} management: * * &lt;p&gt;If any of the operands is of a reference type, unboxing conversion (Section 5.1.8) * is performed. Then:&lt;br&gt; * If either operand is of type {@code BigDecimal}, the other is converted to {@code BigDecimal}.&lt;br&gt; * If either operand is of type double, the other is converted to double.&lt;br&gt; * Otherwise, if either operand is of type float, the other is converted to float.&lt;br&gt; * If either operand is of type {@code BigInteger}, the other is converted to {@code BigInteger}.&lt;br&gt; * Otherwise, if either operand is of type long, the other is converted to long.&lt;br&gt; * Otherwise, both operands are converted to type int. * * @author Andy Clement * @author Juergen Hoeller * @author Sam Brannen * @author Giovanni Dall'Oglio Risso * @author Ben March * @since 0.2.0 */ &nbsp; function createNode(position, left, right) { var node = SpelNode.create('op-multiply', position, left, right); &nbsp; node.getValue = function (state) { var leftValue = left.getValue(state), rightValue = right.getValue(state); &nbsp; if (<span class="missing-if-branch" title="else path not taken" >E</span>typeof leftValue === 'number' &amp;&amp; typeof rightValue === 'number') { return leftValue * rightValue; } &nbsp; //repeats (ex. 'abc' * 2 = 'abcabc') if (<span class="cstat-no" title="statement not covered" >typeof leftValue === 'string' &amp;&amp; typeof rightValue === 'number') {</span> var <span class="cstat-no" title="statement not covered" >s = '',</span> i = 0; for (; <span class="cstat-no" title="statement not covered" >i &lt; rightValue; i += 1) {</span> s += <span class="cstat-no" title="statement not covered" >leftValue;</span> } return <span class="cstat-no" title="statement not covered" >s;</span> } &nbsp; return <span class="cstat-no" title="statement not covered" >null;</span> }; &nbsp; return node; } &nbsp; export var OpMultiply = { create: createNode, }; &nbsp; &nbsp;</pre></td></tr> </table></pre> <div class='push'></div><!-- for sticky footer --> </div><!-- /wrapper --> <div class='footer quiet pad2 space-top1 center small'> Code coverage generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Sep 06 2021 11:09:10 GMT+0800 (中国标准时间) </div> </div> <script src="../../prettify.js"></script> <script> window.onload = function () { if (typeof prettyPrint === 'function') { prettyPrint(); } }; </script> <script src="../../sorter.js"></script> </body> </html>