<commit_before>/*
 * Appcelerator Titanium Mobile
 * Copyright (c) 2011-2012 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */

module.exports = new function() {
	var finish,
		valueOf;
	
	this.init = function(testUtils) {
		finish = testUtils.finish;
		valueOf = testUtils.valueOf;
	}

	this.name = "alarm";
	this.tests = [
		{name: "alarmAdd"},
		{name: "alarmGet"},
		{name: "alarmRemove"},
		{name: "alarmRelative"},
		{name: "alarmAbsolute"}
	]

	this.alarmAdd = function(testRun) {
		var alarm,
			tizenArr,
			date = new Date(2012, 12, 21, 8, 0);

		tizen.alarm.removeAll();
		
		//Alarm in 10 seconds (relative)
		alarm = new tizen.AlarmRelative(10);
		tizen.alarm.add(alarm, "http://tizen.org/alarm-clock");
		
		// Set an alarm on December 21st 2012 08:00
		alarm = new tizen.AlarmAbsolute(date);
		tizen.alarm.add(alarm, "http://tizen.org/alarm-clock");
		
		tizenArr = tizen.alarm.getAll();
		valueOf(testRun, tizenArr.length).shouldBe(2);

		finish(testRun);
	}
	
	this.alarmGet = function(testRun) {	
		var alarm,
			alarm1,
			alarm2, 
			alarm3,
			relative_id,
			absolute_id,
			date = new Date(2012, 12, 21, 8, 0);

		tizen.alarm.removeAll();		
		//Alarm in 10 seconds (relative)
		alarm = new tizen.AlarmRelative(10);
		// Set an alarm on December 21st 2012 08:00
		alarm1 = new tizen.AlarmAbsolute(date);
		tizen.alarm.add(alarm, "http://tizen.org/alarm-clock");
		tizen.alarm.add(alarm1, "http://tizen.org/alarm-clock");
		
		relative_id = alarm.id,
		absolute_id = alarm1.id;

		valueOf(testRun, function(){
			alarm2 = tizen.alarm.get(relative_id);
			alarm3 = tizen.alarm.get(absolute_id);
		}).shouldNotThrowException();

		valueOf(testRun, alarm2 instanceof tizen.AlarmRelative).shouldBeTrue();
		valueOf(testRun, alarm3 instanceof tizen.AlarmAbsolute).shouldBeTrue();

		tizen.alarm.removeAll()

		valueOf(testRun, function(){
			var alarmTmp = tizen.alarm.get(absolute_id);
			alarmTmp = tizen.alarm.get(relative_id);
		}).shouldThrowException();

		finish(testRun);
	}
	
	this.alarmRemove = function(testRun) {
		var alarm,
			alarm1,
			relative_id,
			alarmArr,
			absolute_id,
			date = new Date(2012, 12, 21, 8, 0);
		
		tizen.alarm.removeAll();
		alarmArr = tizen.alarm.getAll();
		valueOf(testRun, alarmArr.length).shouldBe(0);

		//Alarm in 10 seconds (relative)
		alarm = new tizen.AlarmRelative(10);
		alarm1 = new tizen.AlarmAbsolute(date);
		tizen.alarm.add(alarm, "http://tizen.org/alarm-clock");
		tizen.alarm.add(alarm1, "http://tizen.org/alarm-clock");
		relative_id = alarm.id;
		absolute_id = alarm1.id;

		valueOf(testRun, function(){
			tizen.alarm.remove(absolute_id);	
		}).shouldNotThrowException();

		valueOf(testRun, function(){
			tizen.alarm.remove(absolute_id);
		}).shouldThrowException();

		finish(testRun);
	}

	this.alarmRelative = function(testRun) {
		var alarm,
			alarmId,
			delay = 2 * tizen.alarm.PERIOD_MINUTE,
			period = tizen.alarm.PERIOD_HOUR;

		tizen.alarm.removeAll();
		alarm = new tizen.AlarmRelative(delay, period);
		tizen.alarm.add(alarm, "http://tizen.org/alarm-clock");
		alarmId = alarm.id;
		valueOf(testRun, function(){
			var remaining = alarm.getRemainingSeconds();
		}).shouldNotThrowException();
		valueOf(testRun, alarm.delay).shouldBe(delay);

		alarm = tizen.alarm.get(alarmId);
		valueOf(testRun, function(){
			var	fromReaming = alarm.getRemainingSeconds();
		});
		valueOf(testRun, alarm.delay).shouldBe(delay);

		finish(testRun);
	}

	this.alarmAbsolute = function(testRun) {
		tizen.alarm.removeAll();
		var alarm,
			alarmId,
			remaining,
			alarmFrom,
			fromReaming,
			date = new Date(),
			time = date.getTime() + 60000,
			period = tizen.alarm.PERIOD_HOUR;
		
		date.setTime(time);
		alarm = new tizen.AlarmAbsolute(date, period);		
		tizen.alarm.add(alarm, "http://tizen.org/alarm-clock");
		alarmId = alarm.id;
		remaining = alarm.getNextScheduledDate();
		valueOf(testRun, remaining.toDateString()).shouldBe(alarm.date.toDateString());

		alarmFrom = tizen.alarm.get(alarmId),
		fromReaming = alarmFrom.getNextScheduledDate();
		valueOf(testRun, fromReaming.toDateString()).shouldBe(date.toDateString());

		tizen.alarm.removeAll();
		finish(testRun);
	}
}<commit_msg>Fixed Anvil tests for Alarm<commit_after>/*
 * Appcelerator Titanium Mobile
 * Copyright (c) 2011-2012 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */

module.exports = new function() {
	var finish,
		valueOf;
	
	this.init = function(testUtils) {
		finish = testUtils.finish;
		valueOf = testUtils.valueOf;
	}

	this.name = 'alarm';
	this.tests = [
		{name: 'alarmAdd'},
		{name: 'alarmGet'},
		{name: 'alarmRemove'},
		{name: 'alarmRelative'},
		{name: 'alarmAbsolute'}
	]

	this.alarmAdd = function(testRun) {
		var alarm,
			tizenArr,
			date = new Date(2012, 12, 21, 8, 0);

		Ti.Tizen.Alarm.removeAll();
		
		// Alarm in 10 seconds (relative)
		alarm = Ti.Tizen.Alarm.createAlarmRelative({
			delay: 10
		});

		Ti.Tizen.Alarm.add(alarm, 'http://tizen.org/alarm-clock');
		
		// Set an alarm on December 21st 2012 08:00
		alarm = Ti.Tizen.Alarm.createAlarmAbsolute({ 
			date: date
		});

		Ti.Tizen.Alarm.add(alarm, 'http://tizen.org/alarm-clock');
		
		tizenArr = Ti.Tizen.Alarm.getAll();
		valueOf(testRun, tizenArr.length).shouldBe(2);

		finish(testRun);
	}
	
	this.alarmGet = function(testRun) {	
		var alarm,
			alarm1,
			alarm2, 
			alarm3,
			relative_id,
			absolute_id,
			date = new Date(2012, 12, 21, 8, 0);

		Ti.Tizen.Alarm.removeAll();		

		// Alarm in 10 seconds (relative)
		alarm = Ti.Tizen.Alarm.createAlarmRelative({
			delay: 10
		});

		// Set an alarm on December 21st 2012 08:00
		alarm1 = Ti.Tizen.Alarm.createAlarmAbsolute({ 
			date: date
		});

		Ti.Tizen.Alarm.add(alarm, 'http://tizen.org/alarm-clock');
		Ti.Tizen.Alarm.add(alarm1, 'http://tizen.org/alarm-clock');

		relative_id = alarm.id;
		absolute_id = alarm1.id;

		valueOf(testRun, function() {
			alarm2 = Ti.Tizen.Alarm.get(relative_id);
			alarm3 = Ti.Tizen.Alarm.get(absolute_id);
		}).shouldNotThrowException();

		valueOf(testRun, alarm2 instanceof Ti.Tizen.Alarm.AlarmRelative).shouldBeTrue();
		valueOf(testRun, alarm3 instanceof Ti.Tizen.Alarm.AlarmAbsolute).shouldBeTrue();

		Ti.Tizen.Alarm.removeAll();

		valueOf(testRun, function() {
			var alarmTmp = Ti.Tizen.Alarm.get(absolute_id);
			alarmTmp = Ti.Tizen.Alarm.get(relative_id);
		}).shouldThrowException();

		finish(testRun);
	}
	
	this.alarmRemove = function(testRun) {
		var alarm,
			alarm1,
			relative_id,
			alarmArr,
			absolute_id,
			date = new Date(2012, 12, 21, 8, 0);
		
		Ti.Tizen.Alarm.removeAll();
		alarmArr = Ti.Tizen.Alarm.getAll();
		valueOf(testRun, alarmArr.length).shouldBe(0);

		//Alarm in 10 seconds (relative)
		alarm = Ti.Tizen.Alarm.createAlarmRelative({
			delay: 10
		});
		alarm1 = Ti.Tizen.Alarm.createAlarmAbsolute({ 
			date: date
		});
		Ti.Tizen.Alarm.add(alarm, 'http://tizen.org/alarm-clock');
		Ti.Tizen.Alarm.add(alarm1, 'http://tizen.org/alarm-clock');
		relative_id = alarm.id;
		absolute_id = alarm1.id;

		valueOf(testRun, function() {
			Ti.Tizen.Alarm.remove(absolute_id);	
		}).shouldNotThrowException();

		valueOf(testRun, function() {
			Ti.Tizen.Alarm.remove(absolute_id);
		}).shouldThrowException();

		finish(testRun);
	}

	this.alarmRelative = function(testRun) {
		var alarm,
			alarmId,
			delay = 2 * Ti.Tizen.Alarm.PERIOD_MINUTE,
			period = Ti.Tizen.Alarm.PERIOD_HOUR;

		Ti.Tizen.Alarm.removeAll();
		alarm = Ti.Tizen.Alarm.createAlarmRelative({
			delay: delay,
			period: period
		});
		Ti.Tizen.Alarm.add(alarm, 'http://tizen.org/alarm-clock');
		alarmId = alarm.id;

		valueOf(testRun, function() {
			var remaining = alarm.getRemainingSeconds();
		}).shouldNotThrowException();
		valueOf(testRun, alarm.delay).shouldBe(delay);

		alarm = Ti.Tizen.Alarm.get(alarmId);

		valueOf(testRun, function() {
			var fromReaming = alarm.getRemainingSeconds();
		});
		valueOf(testRun, alarm.delay).shouldBe(delay);

		finish(testRun);
	}

	this.alarmAbsolute = function(testRun) {
		Ti.Tizen.Alarm.removeAll();

		var alarm,
			alarmId,
			remaining,
			alarmFrom,
			fromReaming,
			date = new Date(),
			time = date.getTime() + 60000,
			period = Ti.Tizen.Alarm.PERIOD_HOUR;
		
		date.setTime(time);
		alarm = Ti.Tizen.Alarm.createAlarmAbsolute({
			date: date, period: period
		});		
		Ti.Tizen.Alarm.add(alarm, 'http://tizen.org/alarm-clock');
		alarmId = alarm.id;
		remaining = alarm.getNextScheduledDate();

		valueOf(testRun, remaining.toDateString()).shouldBe(alarm.date.toDateString());

		alarmFrom = Ti.Tizen.Alarm.get(alarmId),
		fromReaming = alarmFrom.getNextScheduledDate();

		valueOf(testRun, fromReaming.toDateString()).shouldBe(date.toDateString());

		Ti.Tizen.Alarm.removeAll();
		finish(testRun);
	}
}
{'fraction_non_alphanumeric': 0.14919220055710306, 'fraction_numerical': 0.020501392757660167, 'mean_word_length': 3.8862275449101795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '132068', 'n_tokens_mistral': 3883, 'n_tokens_neox': 3317, 'n_words': 594}