From 5ef31360f7cce01a2181ac28abaebbe9e1a02251 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 20 Aug 2018 14:50:21 -0300 Subject: [PATCH] Add app.transaction() test --- scripts/app_transaction.js | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 scripts/app_transaction.js diff --git a/scripts/app_transaction.js b/scripts/app_transaction.js new file mode 100644 index 000000000..79734d4dd --- /dev/null +++ b/scripts/app_transaction.js @@ -0,0 +1,40 @@ +// Copyright (C) 2018 David Capello +// +// This file is released under the terms of the MIT license. +// Read LICENSE.txt for more information. + +var s = new Sprite(16, 32) +console.assert(s.width == 16) +console.assert(s.height == 32) + +s.width = 20 +console.assert(s.width == 20) +console.assert(s.height == 32) + +s.height = 40 +console.assert(s.width == 20) +console.assert(s.height == 40) + +app.undo() +console.assert(s.width == 20) +console.assert(s.height == 32) + +app.undo() +console.assert(s.width == 16) +console.assert(s.height == 32) + +app.transaction( + function() { + s.width = 20 + s.height = 40 + }) +console.assert(s.width == 20) +console.assert(s.height == 40) + +app.undo() +console.assert(s.width == 16) +console.assert(s.height == 32) + +app.redo() +console.assert(s.width == 20) +console.assert(s.height == 40)