<commit_before>/* Internal helpers */
function AtomicCanvas() {
	// modeled after QUnit's "Keeping Tests Atomic" cookbook guidance:
	//    http://qunitjs.com/cookbook/#keeping_tests_atomic
	this.fixture = $("#qunit-fixture")
	this.fixture.append("<canvas id='atomic-canvas' width='250' height='250'></canvas>")
	this.canvas = document.getElementById('atomic-canvas')
}

/* jCanvas tests */
module("jCanvas Arcs")

test("drawArc, simplest possible", function() {
	var ac = new AtomicCanvas()
	drawArc_simplest("#atomic-canvas")
	QUnit.pixelEqual(ac.canvas, 50, 50, 0, 255, 0, 255)
})

module("jCanvas Layers")

test("addLayer, method drawRect", function () {
	var ac = new AtomicCanvas()
	addLayer_drawRect("#atomic-canvas")
	QUnit.pixelEqual(ac.canvas, 55, 55, 0, 255, 0, 255)
})

asyncTest("animateLayer, method drawLine", 1, function () {
	var ac = new AtomicCanvas()
	animateLayer_drawLine("#atomic-canvas", 0,
		function () {
			QUnit.pixelEqual(ac.canvas, 200, 50, 0, 255, 0, 255)
			QUnit.start()
		})
})

asyncTest("animateLayer, four opacity and position animations", 4, function () {
	var ac = new AtomicCanvas()
	animateLayer_drawLinesInstantShiftVariedOpacity("#atomic-canvas",
		function () {
			QUnit.pixelEqual(ac.canvas, 200, 20, 0, 255, 0, 255)
			QUnit.pixelEqual(ac.canvas, 200, 50, 0, 255, 0, 255)
			QUnit.pixelEqual(ac.canvas, 200, 80, 0, 255, 0, 255)
			QUnit.pixelEqual(ac.canvas, 200, 110, 0, 255, 0, 255)
			QUnit.start()
		})
})

asyncTest("animateLayer, method drawRect", 1, function () {
	var ac = new AtomicCanvas()
	animateLayer_drawRect("#atomic-canvas", 0,
		function () {
			QUnit.pixelEqual(ac.canvas, 115, 65, 0, 255, 0, 255)
			QUnit.start()
		})
})

asyncTest("animateLayer, two addLayers & two animateLayers", 2, function() {
	var ac = new AtomicCanvas()
	// 2013-01-10: this test fails with an animation duration of 0ms, but passes
	//    with a duration of 1ms.  Not sure why, and not worried about it right
	//    now.
	animateLayer_twoAddsTwoAnimates("#atomic-canvas", 1,
		function () {
			QUnit.pixelEqual(ac.canvas,  70, 100, 0, 255, 0, 255)  // rectangle
			QUnit.pixelEqual(ac.canvas, 125, 100, 0, 255, 0, 255)  // circle
			QUnit.start()
		})
})

// DKS (2012-11-24) - not sure test is well formed yet, not working on Chromium or FF
//asyncTest("animateLayerGroup, methods drawRect, drawArc", 1, function() {
//	var ac = new AtomicCanvas()
//	animateLayerGroup_circleRect("#atomic-canvas", 0,
//		function () {
//			QUnit.pixelEqual(ac.canvas,  70, 100, 0, 255, 0, 255)  // rectangle
//			QUnit.start()
//		})
//})

module("jCanvas Transformation")

test("transformation, rotateCanvas", function () {
	var ac = new AtomicCanvas()
	transformation_rotateCanvas("#atomic-canvas", 100, 0)
	// unspecified x, y in above function, so rotation occurs around x:0, y:0
	//    clockwise
	// center of box should be at:
	//    x = cos(30)*100 ~= 87
	//    y = sin(30)*100 ~= 50
	QUnit.pixelEqual(ac.canvas, 87, 50, 0, 255, 0, 255)
})

test("transformation, scaleCanvas", function () {
	var ac = new AtomicCanvas()
	transformation_scaleCanvas("#atomic-canvas", 100, 20)
	// scaling should both shift and balloon the shape
	QUnit.pixelEqual(ac.canvas, 193, 72, 0, 255, 0, 255)
})
<commit_msg>DKS - refactored unit tests to more closely match jCanvas documentation sections.<commit_after>/* Internal helpers */
function AtomicCanvas() {
	// modeled after QUnit's "Keeping Tests Atomic" cookbook guidance:
	//    http://qunitjs.com/cookbook/#keeping_tests_atomic
	this.fixture = $("#qunit-fixture")
	this.fixture.append("<canvas id='atomic-canvas' width='250' height='250'></canvas>")
	this.canvas = document.getElementById('atomic-canvas')
}

/* jCanvas tests */
module("jCanvas Arcs")

test("drawArc, simplest possible", function() {
	var ac = new AtomicCanvas()
	drawArc_simplest("#atomic-canvas")
	QUnit.pixelEqual(ac.canvas, 50, 50, 0, 255, 0, 255)
})

module("jCanvas Layers")

test("addLayer, method drawRect", function () {
	var ac = new AtomicCanvas()
	addLayer_drawRect("#atomic-canvas")
	QUnit.pixelEqual(ac.canvas, 55, 55, 0, 255, 0, 255)
})

asyncTest("animateLayer, method drawLine", 1, function () {
	var ac = new AtomicCanvas()
	animateLayer_drawLine("#atomic-canvas", 0,
		function () {
			QUnit.pixelEqual(ac.canvas, 200, 50, 0, 255, 0, 255)
			QUnit.start()
		})
})

asyncTest("animateLayer, drawLines, instant shift, varied opacity", 4, function () {
	var ac = new AtomicCanvas()
	animateLayer_drawLinesInstantShiftVariedOpacity("#atomic-canvas",
		function () {
			QUnit.pixelEqual(ac.canvas, 200, 20, 0, 255, 0, 255)
			QUnit.pixelEqual(ac.canvas, 200, 50, 0, 255, 0, 255)
			QUnit.pixelEqual(ac.canvas, 200, 80, 0, 255, 0, 255)
			QUnit.pixelEqual(ac.canvas, 200, 110, 0, 255, 0, 255)
			QUnit.start()
		})
})

asyncTest("animateLayer, method drawRect", 1, function () {
	var ac = new AtomicCanvas()
	animateLayer_drawRect("#atomic-canvas", 0,
		function () {
			QUnit.pixelEqual(ac.canvas, 115, 65, 0, 255, 0, 255)
			QUnit.start()
		})
})

asyncTest("animateLayer, two addLayers, two animateLayers", 2, function() {
	var ac = new AtomicCanvas()
	// 2013-01-10: this test fails with an animation duration of 0ms, but passes
	//    with a duration of 1ms.  Not sure why, and not worried about it right
	//    now.
	animateLayer_twoAddsTwoAnimates("#atomic-canvas", 1,
		function () {
			QUnit.pixelEqual(ac.canvas,  70, 100, 0, 255, 0, 255)  // rectangle
			QUnit.pixelEqual(ac.canvas, 125, 100, 0, 255, 0, 255)  // circle
			QUnit.start()
		})
})

// DKS (2012-11-24) - not sure test is well formed yet, not working on Chromium or FF
//asyncTest("animateLayerGroup, methods drawRect, drawArc", 1, function() {
//	var ac = new AtomicCanvas()
//	animateLayerGroup_circleRect("#atomic-canvas", 0,
//		function () {
//			QUnit.pixelEqual(ac.canvas,  70, 100, 0, 255, 0, 255)  // rectangle
//			QUnit.start()
//		})
//})

module("Canvas Rotate")

test("rotateCanvas", function () {
	var ac = new AtomicCanvas()
	transformation_rotateCanvas("#atomic-canvas", 100, 0)
	// unspecified x, y in above function, so rotation occurs around x:0, y:0
	//    clockwise
	// center of box should be at:
	//    x = cos(30)*100 ~= 87
	//    y = sin(30)*100 ~= 50
	QUnit.pixelEqual(ac.canvas, 87, 50, 0, 255, 0, 255)
})

module("Canvas Scale")

test("scaleCanvas", function () {
	var ac = new AtomicCanvas()
	transformation_scaleCanvas("#atomic-canvas", 100, 20)
	// scaling should both shift and balloon the shape
	QUnit.pixelEqual(ac.canvas, 193, 72, 0, 255, 0, 255)
})

{'fraction_non_alphanumeric': 0.15734480639213275, 'fraction_numerical': 0.06945298094652735, 'mean_word_length': 4.125196850393701, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7290222', 'n_tokens_mistral': 2768, 'n_tokens_neox': 2214, 'n_words': 624}