From d3afb683a31919dfc98b8d467fb18022c3139ff8 Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Tue, 18 Oct 2016 16:14:45 +0300 Subject: [PATCH] Update tests expected files --- .../testData/webDemoCanvasExamples/cases/Creatures.kt | 9 +++++---- .../webDemoCanvasExamples/cases/Traffic light.kt | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/js/js.translator/testData/webDemoCanvasExamples/cases/Creatures.kt b/js/js.translator/testData/webDemoCanvasExamples/cases/Creatures.kt index 5deb59fbcfb..e62bc36fad0 100644 --- a/js/js.translator/testData/webDemoCanvasExamples/cases/Creatures.kt +++ b/js/js.translator/testData/webDemoCanvasExamples/cases/Creatures.kt @@ -306,14 +306,15 @@ class RadialGradientGenerator(val context: CanvasRenderingContext2D) { } } -fun v(x: Int, y: Int) = Vector(x, y) -fun v(x: Double, y: Double) = Vector(x.toInt(), y.toInt()) +fun v(x: Double, y: Double) = Vector(x, y) +fun v(x: Int, y: Int) = Vector(x.toDouble(), y.toDouble()) + +class Vector(val x: Double = 0.0, val y: Double = 0.0) { + constructor(x: Int, y: Int) : this(x.toDouble(), y.toDouble()) -class Vector(val x: Int = 0.0, val y: Int = 0.0) { operator fun plus(v: Vector) = v(x + v.x, y + v.y) operator fun unaryMinus() = v(-x, -y) operator fun minus(v: Vector) = v(x - v.x, y - v.y) - operator fun times(koef: Int) = v(x * koef, y * koef) operator fun times(koef: Double) = v(x * koef, y * koef) infix fun distanceTo(v: Vector) = Math.sqrt((this - v).sqr) fun rotatedBy(theta: Double): Vector { diff --git a/js/js.translator/testData/webDemoCanvasExamples/cases/Traffic light.kt b/js/js.translator/testData/webDemoCanvasExamples/cases/Traffic light.kt index 9997b6966e6..676e1325396 100644 --- a/js/js.translator/testData/webDemoCanvasExamples/cases/Traffic light.kt +++ b/js/js.translator/testData/webDemoCanvasExamples/cases/Traffic light.kt @@ -61,7 +61,7 @@ fun main(args: Array) { state.addShape(Button(PATH_TO_IMAGES + "ud.png", v(455.0, 120.0), v(50.0, 120.0))) } -fun v(x: Double, y: Double) = Vector(x.toInt(), y.toInt()) +fun v(x: Double, y: Double) = Vector(x, y) fun v(x: Int, y: Int) = Vector(x, y) class Image(val src: String, override var pos: Vector, var imageSize: Vector) : Shape() { @@ -482,8 +482,9 @@ abstract class Shape() { } -class Vector(val x: Int = 0, val y: Int = 0) { - constructor(x: Double, y: Double) : this(x.toInt(), y.toInt()) +class Vector(val x: Double = 0.0, val y: Double = 0.0) { + constructor(x: Int, y: Int) : this(x.toDouble(), y.toDouble()) + operator fun plus(v: Vector) = v(x + v.x, y + v.y) operator fun unaryMinus() = v(-x, -y) operator fun minus(v: Vector) = v(x - v.x, y - v.y)