Sfoglia il codice sorgente

Updated tests to new format

Yentl Van Tendeloo 9 anni fa
parent
commit
2ec1ad9500

+ 2 - 2
integration/code/binary_to_decimal.alc

@@ -10,8 +10,8 @@ Integer function b2d(param : String):
 	Integer accumul
 	accumul = 1
 
-	while (integer_gte(counter, 0)):
-		if (string_eq(string_get(param, counter), "1")):
+	while (counter >= 0):
+		if (string_get(param, counter) == "1"):
 			value = integer_addition(value, accumul)
 		accumul = integer_multiplication(accumul, 2)
 		counter = integer_subtraction(counter, 1)

+ 2 - 2
integration/code/factorial.alc

@@ -1,10 +1,10 @@
 include "primitives.alh"
 
 Integer function factorial(n : Integer):
-	if(integer_lte(n, 1)):
+	if(n <= 1):
 		return 1
 	else:
-		return integer_multiplication(n, factorial(integer_subtraction(n, 1)))
+		return n * factorial(n - 1)
 
 Void function main():
 	while(True):

+ 2 - 2
integration/code/fibonacci.alc

@@ -1,10 +1,10 @@
 include "primitives.alh"
 
 Integer function fib(param : Integer):
-	if (integer_lte(param, 2)):
+	if (param <= 2):
 		return 1
 	else:
-		return integer_addition(fib(integer_subtraction(param, 1)), fib(integer_subtraction(param, 2)))
+		return fib(param - 1) + fib(param - 2)
 
 Void function main():
 	while(True):

+ 3 - 3
integration/code/fibonacci_smart.alc

@@ -4,10 +4,10 @@ Element numbers = ?
 
 Integer function fib(param : Integer):
 	Integer new
-	while (integer_gt(param, list_len(numbers))):
+	while (param > list_len(numbers)):
 		new = list_len(numbers)
-		list_append(numbers, integer_addition(dict_read(numbers, integer_subtraction(new, 2)), dict_read(numbers, integer_subtraction(new, 1))))
-	return dict_read(numbers, integer_subtraction(param, 1))
+		list_append(numbers, integer_addition(dict_read(numbers, new - 2), dict_read(numbers, new - 1)))
+	return dict_read(numbers, param - 1)
 
 Void function main():
 	numbers = create_node()

+ 2 - 2
integration/code/if_elif.alc

@@ -1,9 +1,9 @@
 include "primitives.alh"
 
 Integer function compare_with_zero(n : Integer):
-	if(integer_lt(n, 0)):
+	if(n < 0):
 		return -1
-	elif(integer_eq(n, 0)):
+	elif(n == 0):
 		return 0
 	return 1
 

+ 2 - 2
integration/code/if_elif_else.alc

@@ -1,9 +1,9 @@
 include "primitives.alh"
 
 Integer function compare_with_zero(n : Integer):
-	if(integer_lt(n, 0)):
+	if(n < 0):
 		return -1
-	elif(integer_eq(n, 0)):
+	elif(n == 0):
 		return 0
 	else:
 		return 1

+ 2 - 2
integration/code/leap_year.alc

@@ -2,9 +2,9 @@ include "lib_remainder.alc"
 
 Boolean function leap_year(year : Integer):
 	// Is a leap year if it is divisible by 4
-	if (integer_eq(remainder(year, 4), 0)):
+	if (remainder(year, 4) == 0):
 		// Unless it is also divisible by 1000
-		if (integer_eq(remainder(year, 1000), 0)):
+		if (remainder(year, 1000) == 0):
 			return False
 		else:
 			return True

+ 1 - 1
integration/code/lib_remainder.alc

@@ -1,4 +1,4 @@
 include "primitives.alh"
 
 Integer function remainder(a : Integer, b: Integer):
-	return integer_subtraction(a, integer_multiplication(integer_division(a, b), b))
+	return a - ((a / b) * b)

+ 2 - 2
integration/code/power.alc

@@ -1,10 +1,10 @@
 include "primitives.alh"
 
 Integer function power(base : Integer, exponent : Integer):
-	if (integer_eq(exponent, 0)):
+	if (exponent == 0):
 		return 1
 	else:
-		return integer_multiplication(base, power(base, integer_subtraction(exponent, 1)))
+		return base * power(base, exponent - 1)
 
 Void function main():
 	while (True):

+ 2 - 2
integration/code/revert.alc

@@ -10,9 +10,9 @@ String function revert_string(a : String):
 	String result
 	result = ""
 
-	while (integer_lt(counter, length)):
+	while (counter < length):
 		result = string_join(string_get(a, counter), result)
-		counter = integer_addition(counter, 1)
+		counter = counter + 1
 
 	return result
 

+ 0 - 1
interface/HUTN/includes/primitives.alh

@@ -30,7 +30,6 @@ Float function cast_b2f(a: Boolean)
 String function cast_b2s(a: Boolean) 
 String function cast_e2s(a: Element) 
 String function cast_a2s(a: Action) 
-String function cast_t2s(a: Type) 
 String function cast_v2s(a: Element) 
 String function cast_id2s(a: Element) 
 Element function dict_add(a: Element, b: Element, c: Element)