fix-Change // test_output! output to //! test_output(output) in input folder

This commit is contained in:
Tarun Samanta
2023-05-30 15:38:47 +05:30
parent 0adcd150ec
commit a86ac976b2
81 changed files with 88 additions and 87 deletions

View File

@@ -1,4 +1,4 @@
// test_output! {"right":"right"}
//! test_output({"right":"right"})
// (This is wrong.)
// Note: The reason for the error (at the time of writing) is not actually
// evaluation order but the use of the *register* %key for the left side. `key`

View File

@@ -1,4 +1,4 @@
// test_output! 4
//! test_output(4)
// (This is wrong.)
export default function main() {

View File

@@ -1,4 +1,4 @@
// test_output! [["1.20e+2","1.22e+2","1.22e+2","1.24e+2","1.24e+2"],["1.21e+0","1.22e+0","1.23e+0","1.24e+0","1.25e+0"]]
//! test_output([["1.20e+2","1.22e+2","1.22e+2","1.24e+2","1.24e+2"],["1.21e+0","1.22e+0","1.23e+0","1.24e+0","1.25e+0"]])
// This is wrong. There's some inconsistent banker's rounding going on.
// It appears to be inherent to rust's {:.*e} formatting - a technical oversight?
// Or maybe it has to do with parsing the source string into a number imprecisely?

View File

@@ -1,4 +1,4 @@
// test_output! ["🚀","","","","🍹","","","","a","b","c","£","","한","","","🎨","","",""]
//! test_output(["🚀","","","","🍹","","","","a","b","c","£","","한","","","🎨","","",""])
// This is wrong. It should be: ["🚀","🍹","a","b","c","£","한","🎨"].
// The reason is that for-of is currently approximated using indexing from 0 to .length. This is
// expected to be fixed when iterators are added to the language.

View File

@@ -1,4 +1,4 @@
// test_output! [true,false,false,[1,2,3],["a","b","c"],[],[1,2,3],[],[,,],[3,1],[true]]
//! test_output([true,false,false,[1,2,3],["a","b","c"],[],[1,2,3],[],[,,],[3,1],[true]])
export default function () {
return [

View File

@@ -1,4 +1,4 @@
// test_output! ["a","b"]
//! test_output(["a","b"])
export default function main() {
let log = [];

View File

@@ -1,4 +1,4 @@
// test_output! E: TypeError{"message":"Cannot mix BigInt and other types"}
//! test_output(E: TypeError{"message":"Cannot mix BigInt and other types"})
export default function () {
return 1 + (1n as unknown as number);

View File

@@ -1,4 +1,4 @@
// test_output! [[1,2,5],[1,2,3,4,5]]
//! test_output([[1,2,5],[1,2,3,4,5]])
export default function main() {
let tree = BinaryTree();

View File

@@ -1,4 +1,4 @@
// test_output! [true,false,false,true,true,true,true,false,true,false,false,false]
//! test_output([true,false,false,true,true,true,true,false,true,false,false,false])
export default function () {
return [

View File

@@ -1,4 +1,4 @@
// test_output! ["c","a","b"]
//! test_output(["c","a","b"])
export default function main() {
let log = [];

View File

@@ -1,4 +1,4 @@
// test_output! [1,2,3]
//! test_output([1,2,3])
export default function main() {
let c = Counter();

View File

@@ -1,4 +1,4 @@
// test_output! 3
//! test_output(3)
export default function main() {
const [a, b] = [1, 2];

View File

@@ -1,4 +1,4 @@
// test_ouput! 42
//! test_output(42)
export default function main() {
const [[[{ x: { y: [[{ z }]] } }]]] = [[[{ x: { y: [[{ z: 42 }]] } }]]];

View File

@@ -1,4 +1,4 @@
// test_output! [55,145,237,43,31]
//! test_output([55,145,237,43,31])
export default function main() {
let res = [];

View File

@@ -1,4 +1,4 @@
// test_output! 3
//! test_output(3)
export default function main() {
const { a, b } = { a: 1, b: 2 };

View File

@@ -1,4 +1,4 @@
// test_output! 3
//! test_output(3)
export default function main() {
return foo([1, 2]);

View File

@@ -1,4 +1,4 @@
// test_ouput! 42
//! test_output(42)
export default function main() {
return foo([[[{ x: { y: [[{ z: 42 }]] } }]]]);

View File

@@ -1,4 +1,4 @@
// test_output! [55,145,237,43,31]
//! test_output([55,145,237,43,31])
export default function main() {
return [

View File

@@ -1,4 +1,4 @@
// test_output! 3
//! test_output(3)
export default function main() {
return foo({ a: 1, b: 2 });

View File

@@ -1,4 +1,4 @@
// test_output! [1,4,9]
//! test_output([1,4,9])
export default function () {
let vals: number[] = [];

View File

@@ -1,4 +1,4 @@
// test_output! "Hello world!"
//! test_output("Hello world!")
export default function main() {
return 'Hello world!';

View File

@@ -1,4 +1,4 @@
// test_output! ["this is the bar function","this is the bar function"]
//! test_output(["this is the bar function","this is the bar function"])
import { bar, barExported } from "./helpers/bar.ts";

View File

@@ -1,4 +1,4 @@
// test_output! "this is the foo function"
//! test_output("this is the foo function")
import foo from "./helpers/foo.ts";

View File

@@ -1,4 +1,4 @@
// test_output! ["this is the foo function","this is the bar function"]
//! test_output(["this is the foo function","this is the bar function"])
import { bar, foo } from "./helpers/fooAndBar.ts";

View File

@@ -1,4 +1,4 @@
// test_output! ["this is the foo function","this is the bar function"]
//! test_output(["this is the foo function","this is the bar function"])
import foobar from "./helpers/foobar.ts";

View File

@@ -1,4 +1,4 @@
// test_output! [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]
//! test_output([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])
export default function main() {
const x = [7, 18, 9, 11, 16, 3, 8, 2, 5, 4, 6, 14, 15, 17, 10, 12, 1, 13];

View File

@@ -1,4 +1,4 @@
// test_output (TODO broken!) [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]
// test_output((TODO broken!) [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])
declare const Debug: {
log: (...args: unknown[]) => undefined;

View File

@@ -1,4 +1,4 @@
// test_output! [1,1]
//! test_output([1,1])
export default function main() {
let a;

View File

@@ -1,4 +1,4 @@
// test_output! [17,15,12]
//! test_output([17,15,12])
export default function main() {
let a = 2;

View File

@@ -1,4 +1,4 @@
// test_output! [1,4,9]
//! test_output([1,4,9])
export default function main() {
let x = 0;

View File

@@ -1,4 +1,4 @@
// test_output! [1,5,14]
//! test_output([1,5,14])
export default function main() {
let x = 0;

View File

@@ -1,4 +1,4 @@
// test_output! [[true,true,true,true,true,true,true],[false,false,false,false,false]]
//! test_output([[true,true,true,true,true,true,true],[false,false,false,false,false]])
export default function () {
const integers = [

View File

@@ -1,4 +1,4 @@
// test_output! [[true,true,true,true,true,true],[false,false,false,false,false,false]]
//! test_output([[true,true,true,true,true,true],[false,false,false,false,false,false]])
export default function () {
const minSafe = -9007199254740991;

View File

@@ -1,4 +1,4 @@
// test_output! [[37,-37,37.1,37,37.1,1.5,0.1,1.23],[NaN]]
//! test_output([[37,-37,37.1,37,37.1,1.5,0.1,1.23],[NaN]])
export default function () {
const numbers = [

View File

@@ -1,4 +1,4 @@
// test_output! [[37,-37,15,37,37,31],[NaN,NaN]]
//! test_output([[37,-37,15,37,37,31],[NaN,NaN]])
export default function () {
const positive_and_negative = [

View File

@@ -1,4 +1,4 @@
// test_output! [["0e+0","1.2e+0","1.2e+1","1.2e+2","1.2e-1","1.2e-2","1.2e-3","1.2e-4"],["0.00e+0","1.23e+0","1.23e+1","1.23e-1","1.23e-2","1.23e-3","1.23e-4"],["NaN","Infinity"]]
//! test_output([["0e+0","1.2e+0","1.2e+1","1.2e+2","1.2e-1","1.2e-2","1.2e-3","1.2e-4"],["0.00e+0","1.23e+0","1.23e+1","1.23e-1","1.23e-2","1.23e-3","1.23e-4"],["NaN","Infinity"]])
export default function () {
const withoutPrecision = [

View File

@@ -1,4 +1,4 @@
// test_output! [["0.00","1.23","123.00","0.01","0.00123","12345.68","3.14","-1.00"],["NaN","Infinity"]]
//! test_output([["0.00","1.23","123.00","0.01","0.00123","12345.68","3.14","-1.00"],["NaN","Infinity"]])
export default function () {
const positive = [

View File

@@ -1,4 +1,4 @@
// test_output! "right"
//! test_output("right")
export default function main() {
let x;

View File

@@ -1,4 +1,4 @@
// test_output! ["c","a","b"]
//! test_output(["c","a","b"])
export default function main() {
let log: string[] = [];

View File

@@ -1,4 +1,4 @@
// test_output! 2
//! test_output(2)
export default function main() {
let value = 1;

View File

@@ -1,4 +1,4 @@
// test_output! 233168
//! test_output(233168)
export default function main() {
let sum = 0;

View File

@@ -1,4 +1,4 @@
// test_output! 70600674
//! test_output(70600674)
export default function main() {
const grid = [

View File

@@ -1,4 +1,4 @@
// test_output! "Probably 5537376230 (trailing digits: 39036)"
//! test_output("Probably 5537376230 (trailing digits: 39036)")
export default function main() {
const numStrs = [

View File

@@ -1,4 +1,4 @@
// test_output! 137846528820
//! test_output(137846528820)
export default function main() {
let rc = new RouteCalculator();

View File

@@ -1,4 +1,4 @@
// test_output! 1366
//! test_output(1366)
import plus from "./helpers/plus.ts";

View File

@@ -1,4 +1,4 @@
// test_output! 1074
//! test_output(1074)
export default function main() {
const tower = [

View File

@@ -1,4 +1,4 @@
// test_output! 171
//! test_output(171)
declare const Debug: {
log: (...args: unknown[]) => undefined;

View File

@@ -1,4 +1,4 @@
// test_output! 4613732
//! test_output(4613732)
export default function main() {
let sum = 0;

View File

@@ -1,4 +1,4 @@
// test_output! 4782
//! test_output(4782)
export default function main() {
let fibLast = 1n;

View File

@@ -1,4 +1,4 @@
// test_output! [71,839,1471,6857]
//! test_output([71,839,1471,6857])
import { factorize } from "./helpers/primes.ts";

View File

@@ -1,4 +1,4 @@
// test_output! 906609
//! test_output(906609)
export default function main() {
let largest = 0;

View File

@@ -1,4 +1,4 @@
// test_output! 232792560
//! test_output(232792560)
import { factorize } from "./helpers/primes.ts";

View File

@@ -1,4 +1,4 @@
// test_output! 25164150
//! test_output(25164150)
export default function main() {
return squareOfSum(100) - sumOfSquares(100);

View File

@@ -1,4 +1,4 @@
// test_output! 23514624000
//! test_output(23514624000)
export default function main() {
const digits = [

View File

@@ -1,4 +1,4 @@
// test_output! 31875000
//! test_output(31875000)
export default function main() {
for (let a = 1; a <= 1000; a++) {

View File

@@ -1,4 +1,4 @@
// test_output! false
//! test_output(false)
export default function main() {
const leftBowl = ["apple", "mango"];

View File

@@ -1,4 +1,4 @@
// test_output! 3
//! test_output(3)
export default function main() {
let sum = 0;

View File

@@ -1,4 +1,4 @@
// test_output! [undefined,"🚀","","","","🍹","","","","a","b","c","£","","한","","","🎨","","","",undefined]
//! test_output([undefined,"🚀","","","","🍹","","","","a","b","c","£","","한","","","🎨","","","",undefined])
export default function () {
const str = "🚀🍹abc£한🎨";

View File

@@ -1,4 +1,4 @@
// test_output! "r"
//! test_output("r")
export default function() {
return "foobar".at(-1);

View File

@@ -1,4 +1,4 @@
// test_output! [128640,undefined,undefined,undefined,127865,undefined,undefined,undefined,97,98,99,163,undefined,54620,undefined,undefined,127912,undefined,undefined,undefined]
//! test_output([128640,undefined,undefined,undefined,127865,undefined,undefined,undefined,97,98,99,163,undefined,54620,undefined,undefined,127912,undefined,undefined,undefined])
// ValueScript uses utf8, so it deviates from JavaScript's utf16.
// We're also not really doing the utf8 equivalent of JavaScript's utf16 either.

View File

@@ -1,4 +1,4 @@
// test_output! [true,false,true,true,true,true,false,true,true,false]
//! test_output([true,false,true,true,true,true,false,true,true,false])
export default function () {
return [

View File

@@ -1,4 +1,4 @@
// test_output! "Hi 👋"
//! test_output("Hi 👋")
export default function () {
return String.fromCodePoint(72, 105, 32, 128075);

View File

@@ -1,4 +1,4 @@
// test_output! [[true,true,true,true,true,true],[false,false,false,false]]
//! test_output([[true,true,true,true,true,true],[false,false,false,false]])
export default function () {
const positive = [

View File

@@ -1,4 +1,4 @@
// test_output! [[0,3,1,0,0,3],[-1,-1,-1,-1]]
//! test_output([[0,3,1,0,0,3],[-1,-1,-1,-1]])
export default function () {
const positive = [

View File

@@ -1,4 +1,4 @@
// test_output! [[4,2,4,6],[-1,-1]]
//! test_output([[4,2,4,6],[-1,-1]])
export default function () {
const positive = [

View File

@@ -1,4 +1,4 @@
// test_output! ["foo ","🚀","🚀","🚀","🚀","🚀","🚀🚀","🚀🚀","abc12","abc123","abc1231","abc12312"]
//! test_output(["foo ","🚀","🚀","🚀","🚀","🚀","🚀🚀","🚀🚀","abc12","abc123","abc1231","abc12312"])
export default function () {
return [

View File

@@ -1,4 +1,4 @@
// test_output! [" foo","🚀","🚀","🚀","🚀","🚀","🚀🚀","🚀🚀","12abc","123abc","1231abc","12312abc"]
//! test_output([" foo","🚀","🚀","🚀","🚀","🚀","🚀🚀","🚀🚀","12abc","123abc","1231abc","12312abc"])
export default function () {
return [

View File

@@ -1,4 +1,4 @@
// test_output! "foofoofoo"
//! test_output("foofoofoo")
export default function () {
return "foo".repeat(3);

View File

@@ -1,4 +1,4 @@
// test_output! ["","","","🎨","🎨","🎨","한🎨","한🎨","🍹abc£한","🚀🍹abc£한🎨","🚀🍹abc£한🎨","🚀🍹abc£한🎨",""]
//! test_output(["","","","🎨","🎨","🎨","한🎨","한🎨","🍹abc£한","🚀🍹abc£한🎨","🚀🍹abc£한🎨","🚀🍹abc£한🎨",""])
export default function () {
const str = "🚀🍹abc£한🎨";

View File

@@ -1,4 +1,4 @@
// test_output! [["🚀","🍹","a","b","c","£","한","🎨"],["f","","bar"],["","bar"],["foo",""],["one","two","three"]]
//! test_output([["🚀","🍹","a","b","c","£","한","🎨"],["f","","bar"],["","bar"],["foo",""],["one","two","three"]])
export default function () {
return [

View File

@@ -1,4 +1,4 @@
// test_output! [[true,false,true,false,false,true]]
//! test_output([[true,false,true,false,false,true]])
export default function () {
const startsWithTests = [

View File

@@ -1,4 +1,4 @@
// test_output! [["abc","de","abcde","cde","bcd"],["","abc",""],["abc","cde","bcd"]]
//! test_output([["abc","de","abcde","cde","bcd"],["","abc",""],["abc","cde","bcd"]])
export default function () {
const positive = [

View File

@@ -1,4 +1,4 @@
// test_output! [["abc","xyz","a1b2c3","hello world","áéíóú"]]
//! test_output([["abc","xyz","a1b2c3","hello world","áéíóú"]])
export default function () {
const toLowerCaseTests = [

View File

@@ -1,4 +1,4 @@
// test_output! [["ABC","XYZ","A1B2C3","HELLO WORLD","ÁÉÍÓÚ"]]
//! test_output([["ABC","XYZ","A1B2C3","HELLO WORLD","ÁÉÍÓÚ"]])
export default function () {
const toUpperCaseTests = [

View File

@@ -1,4 +1,4 @@
// test_output! [["abc","abc","abc","a b c",""]]
//! test_output([["abc","abc","abc","a b c",""]])
export default function () {
const trimTests = [

View File

@@ -1,4 +1,4 @@
// test_output! [["abc"," abc"," abc"," a b c",""]]
//! test_output([["abc"," abc"," abc"," a b c",""]])
export default function () {
const trimEndTests = [

View File

@@ -1,4 +1,4 @@
// test_output! [["abc","abc ","abc ","a b c ",""]]
//! test_output([["abc","abc ","abc ","a b c ",""]])
export default function () {
const trimStartTests = [

View File

@@ -1,4 +1,4 @@
// test_output! ["b","a"]
//! test_output(["b","a"])
export default function main() {
const x = ['a', 'b'];

View File

@@ -1,4 +1,4 @@
// test_output! [[1,2,5],[1,2,3,4,5]]
//! test_output([[1,2,5],[1,2,3,4,5]])
import BinaryTree from "./helpers/BinaryTree.ts";

View File

@@ -1,4 +1,4 @@
// test_output! 3
//! test_output(3)
export default function main() {
const x = 3;

View File

@@ -3,11 +3,12 @@ mod tests {
use std::collections::HashSet;
use std::fs;
use std::path::{Path, PathBuf};
use std::rc::Rc;
use valuescript_compiler::compile;
use valuescript_compiler::{assemble, parse_module};
use valuescript_vm::ValTrait;
use valuescript_vm::VirtualMachine;
use valuescript_vm::{Bytecode, ValTrait};
use crate::handle_diagnostics_cli::handle_diagnostics_cli;
use crate::resolve_entry_path::resolve_entry_path;
@@ -32,11 +33,11 @@ mod tests {
let file_contents = fs::read_to_string(&file_path).expect("Failed to read file contents");
if let Some(first_line) = file_contents.lines().next() {
if first_line.starts_with("//! test_output ") {
if first_line.starts_with("// test_output! ") {
println!("\nTesting {} ...", file_path.to_str().unwrap());
let output_str = first_line
.split_once("//! test_output ")
.split_once("// test_output! ")
.map(|x| x.1)
.unwrap_or("");
@@ -70,20 +71,20 @@ mod tests {
.module
.expect("Should have exited if module is None");
let bytecode = assemble(&module);
let bytecode = Rc::new(Bytecode::new(assemble(&module)));
let assembly = module.to_string();
let parsed_assembly = parse_module(&assembly);
let bytecode_via_assembly = assemble(&parsed_assembly);
if bytecode != bytecode_via_assembly {
if bytecode.code != bytecode_via_assembly {
println!(" Bytecode mismatch between original and parsed assembly");
failed_paths.insert(file_path.clone());
}
let mut vm = VirtualMachine::new();
let result = vm.run(&bytecode, &[]);
let result = vm.run(bytecode, Some(2_000_000), &[]);
let result_str = match result {
Ok(val) => val.codify(),
@@ -120,4 +121,4 @@ mod tests {
}
Ok(files)
}
}
}