public void AbsWithDoubleInputReturnsCorrectResult() { var function = new Abs(); var result = function.Execute(FunctionsHelper.CreateArgs(4.67), this.ParsingContext); Assert.AreEqual(4.67d, result.Result); }
public void CalculateTest(double argument, double result, double accracy) { var testingFunction = new Abs(); var testResult = testingFunction.Calculate(argument); Assert.AreEqual(result, testResult, accracy); }
public void AbsWithPositiveIntegerReturnsCorrectResult() { var function = new Abs(); var result = function.Execute(FunctionsHelper.CreateArgs(10), this.ParsingContext); Assert.AreEqual(10d, result.Result); }
public void AbsWithDatesAsStringReturnsCorrectValue() { var function = new Abs(); var result = function.Execute(FunctionsHelper.CreateArgs("5/5/2017"), this.ParsingContext); Assert.AreEqual(42860d, result.Result); }
public void AbsWithFalseBooleanReturnsCorrectValue() { var function = new Abs(); var result = function.Execute(FunctionsHelper.CreateArgs(false), this.ParsingContext); Assert.AreEqual(0d, result.Result); }
public void CalculationTest(double value, double answer) { var calculator = new Abs(); double actual = calculator.calculate(value); Assert.AreEqual(answer, actual, 0.00); }
public void AbsWithNumericStringReturnsCorrectValue() { var function = new Abs(); var result = function.Execute(FunctionsHelper.CreateArgs("-89"), this.ParsingContext); Assert.AreEqual(89d, result.Result); }
public void NoModuleTest() { var module = new Abs(); var source = module.SourceModules[0]; Assert.Null(source); }
public void CalculateTest(double argument, double result) { var calculator = new Abs(); var testResult = calculator.Calculate(argument); Assert.AreEqual(result, testResult); }
public void CloneTest() { var exp = new Abs(new Number(0)); var clone = exp.Clone(); Assert.Equal(exp, clone); }
public void AbsWithGeneralStringInputReturnsPoundValue() { var function = new Abs(); var result = function.Execute(FunctionsHelper.CreateArgs("string"), this.ParsingContext); Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type); }
public void CalculateTest(double firstValue, double expected) { var calculator = new Abs(); var actualResult = calculator.Calculate(firstValue); Assert.AreEqual(expected, actualResult); }
public bool Visit(Abs abs) { abs.Parents.Clear(); abs.Arg.Accept(this); UpdateInterval(abs, 0, Double.PositiveInfinity); return(true); }
public void InvalidGetSourceModule_NoModule_Test() { var module = new Abs(); var source = module.SourceModules[0]; Assert.IsNull(source); }
public override void Generate(Map map, GenStepParams parms) { ModuleBase chambers = new Perlin(0.010, 1.7, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High); ModuleBase columns = new Perlin(0.150, 0.5, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High); columns = new ScaleBias(0.5, 0.5, columns); // push columns to the centers of chambers ModuleBase columnsNoise = new Invert(chambers); columnsNoise = new ScaleBias(3f, -2f, columnsNoise); columnsNoise = new Min(new Const(0.0), columnsNoise); columns = new Add(columns, columnsNoise); // broken tunnel network ModuleBase tunnels = new Perlin(0.01, 1.7, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High); ModuleBase tunnelsNoise = new Perlin(0.005, 0.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.Medium); tunnels = new Abs(tunnels); tunnels = new Add(new Const(0.5), tunnels); tunnels = new Add(tunnels, new Clamp(0, 0.5, tunnelsNoise)); chambers = new Min(new Add(chambers, new Const(0.75)), tunnels); MapGenFloatGrid elevation = MapGenerator.Elevation; foreach (IntVec3 cell in map.AllCells) { elevation[cell] = Math.Max(columns.GetValue(cell), chambers.GetValue(cell)); } }
public ActionResult DeleteConfirmed(int id) { Abs abs = db.Abs.Find(id); db.Abs.Remove(abs); db.SaveChanges(); return(RedirectToAction("Index")); }
public static bool IsVal(Context ctx, ITerm t) { return(t switch { True _ => true, False _ => true, Abs _ => true, _ => false });
public bool Visit(Abs abs) { if (UpdateInterval(abs.Arg, -abs.Max, abs.Max)) { AddChanged(abs.Arg); return(true); } return(false); }
public void DoubleFunctionNegativeAbs() { var sut = new Abs(); var result = sut.Execute(new List <Accumulator> { new Accumulator(-0.5) }); Assert.AreEqual(0.5, result.ValueAsDouble()); }
public void AbsShouldReturnCorrectResult() { var expectedValue = 3d; var func = new Abs(); var args = FunctionsHelper.CreateArgs(-3d); var result = func.Execute(args, _parsingContext); Assert.AreEqual(expectedValue, result.Result); }
public void SourceIndexOutOfRangeTest() { var module = new Abs(); #pragma warning disable CS0251 // Indexing an array with a negative index Assert.Throws <IndexOutOfRangeException>(() => module.SourceModules[-1]); #pragma warning restore CS0251 // Indexing an array with a negative index Assert.Throws <IndexOutOfRangeException>(() => module.SourceModules[module.SourceModuleCount]); Assert.Throws <IndexOutOfRangeException>(() => module.SourceModules[module.SourceModuleCount + 2]); }
public ActionResult Edit([Bind(Include = "AbsId,Picure,Instructions,Benefits,Sets")] Abs abs) { if (ModelState.IsValid) { db.Entry(abs).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(abs)); }
public ActionResult Create([Bind(Include = "AbsId,Picure,Instructions,Benefits,Sets")] Abs abs) { if (ModelState.IsValid) { db.Abs.Add(abs); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(abs)); }
public void EvalLambdaAbstraction() { // Arrange var v = new Abs(new Var(0, 0), "x"); // Act var t = Eval(EmptyContext, v); // Assert Assert.IsType <Abs>(t); }
public void AbsTest(double data) { var source = new Constant { ConstantValue = data }; var module = new Abs { Source0 = source }; Assert.Equal(Math.Abs(source.GetValue(0, 0, 0)), module.GetValue(0, 0, 0)); }
// this mod a public BigInteger Modulo(BigInteger a) { var result = new BigInteger(); Abs.DivideRemainderTo(a, null, result); if (sign < 0 && result.CompareTo(Zero) > 0) { a.SubtractTo(result, result); } return(result); }
/// <summary> /// Analyzes the specified expression. /// </summary> /// <param name="exp">The expression.</param> /// <returns> /// The result of analysis. /// </returns> public override IExpression Analyze(Abs exp) { if (!Helpers.HasVariable(exp, Variable)) { return(new Number(0)); } var div = new Div(exp.Argument.Clone(), exp.Clone()); var mul = new Mul(exp.Argument.Clone().Analyze(this), div); return(mul); }
public void AbsTest() { var source = new Constant() { ConstantValue = -1 }; var module = new Abs() { Source0 = source }; Assert.AreEqual(Math.Abs(source.GetValue(0, 0, 0)), module.GetValue(0, 0, 0)); }
// GET: Abs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Abs abs = db.Abs.Find(id); if (abs == null) { return(HttpNotFound()); } return(View(abs)); }
public static ITerm TmMap(Func <int, Var, ITerm> onVar, int c, ITerm t) { ITerm Walk(int c, ITerm t) { return(t switch { Var var => onVar(c, var), Abs abs => new Abs(abs.Info, Walk(c + 1, abs.Body), abs.BoundedVariable, abs.Type), App app => new App(app.Info, Walk(c, app.Left), Walk(c, app.Right)), True e => e, False f => f, If ift => new If(ift.Info, Walk(c, ift.Condition), Walk(c, ift.Then), Walk(c, ift.Else)), _ => throw new InvalidOperationException() }); }
public virtual void loadFunctions(Rete engine) { Abs abs = new Abs(); engine.declareFunction(abs); funcs.Add(abs); Acos acos = new Acos(); engine.declareFunction(acos); funcs.Add(acos); Add add = new Add(); engine.declareFunction(add); funcs.Add(add); Asin asin = new Asin(); engine.declareFunction(asin); funcs.Add(asin); Atan atan = new Atan(); engine.declareFunction(atan); funcs.Add(atan); Ceil ceil = new Ceil(); engine.declareFunction(ceil); funcs.Add(ceil); Const cnst = new Const(); engine.declareFunction(cnst); funcs.Add(cnst); Cos cos = new Cos(); engine.declareFunction(cos); funcs.Add(cos); Degrees degrees = new Degrees(); engine.declareFunction(degrees); funcs.Add(degrees); Divide div = new Divide(); engine.declareFunction(div); funcs.Add(div); EqFunction eqf = new EqFunction(); engine.declareFunction(eqf); funcs.Add(eqf); Evenp evenp = new Evenp(); engine.declareFunction(evenp); funcs.Add(evenp); Exp exp = new Exp(); engine.declareFunction(exp); funcs.Add(exp); Floor floor = new Floor(); engine.declareFunction(floor); funcs.Add(floor); Greater gr = new Greater(); engine.declareFunction(gr); funcs.Add(gr); GreaterOrEqual gre = new GreaterOrEqual(); engine.declareFunction(gre); funcs.Add(gre); Less le = new Less(); engine.declareFunction(le); funcs.Add(le); LessOrEqual leoe = new LessOrEqual(); engine.declareFunction(leoe); funcs.Add(leoe); Log log = new Log(); engine.declareFunction(log); funcs.Add(log); Max max = new Max(); engine.declareFunction(max); funcs.Add(max); Min min = new Min(); engine.declareFunction(min); funcs.Add(min); Multiply mul = new Multiply(); engine.declareFunction(mul); funcs.Add(mul); NeqFunction neq = new NeqFunction(); engine.declareFunction(neq); funcs.Add(neq); Oddp oddp = new Oddp(); engine.declareFunction(oddp); funcs.Add(oddp); Pow pow = new Pow(); engine.declareFunction(pow); funcs.Add(pow); Radians radians = new Radians(); engine.declareFunction(radians); funcs.Add(radians); Random random = new Random(); engine.declareFunction(random); funcs.Add(random); Rint rint = new Rint(); engine.declareFunction(rint); funcs.Add(rint); Round round = new Round(); engine.declareFunction(round); funcs.Add(round); Sin sin = new Sin(); engine.declareFunction(sin); funcs.Add(sin); Sqrt sqrt = new Sqrt(); engine.declareFunction(sqrt); funcs.Add(sqrt); Subtract sub = new Subtract(); engine.declareFunction(sub); funcs.Add(sub); Tan tan = new Tan(); engine.declareFunction(tan); funcs.Add(tan); // now we Add the functions under alias engine.declareFunction("+", add); engine.declareFunction("-", sub); engine.declareFunction("*", mul); engine.declareFunction("/", div); engine.declareFunction("**", pow); engine.declareFunction(">", gr); engine.declareFunction(">=", gre); engine.declareFunction("<", le); engine.declareFunction("<=", leoe); }