forked from cory/tildefriends
		
	Merge branches/quickjs to trunk. This is the way.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3621 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		@@ -4,4 +4,5 @@ cat > test.js << EOF
 | 
			
		||||
print("hi");
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
echo $TILDEFRIENDS test.js
 | 
			
		||||
$TILDEFRIENDS test.js
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,8 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
echo "SKIP"
 | 
			
		||||
exit 0
 | 
			
		||||
 | 
			
		||||
if [ ! -x /usr/bin/valgrind ]; then
 | 
			
		||||
	echo "SKIP"
 | 
			
		||||
	exit 0
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ task.onExit = function() {
 | 
			
		||||
	print("child exited");
 | 
			
		||||
};
 | 
			
		||||
task.activate();
 | 
			
		||||
task.execute({name: "child.js", source: File.readFile("child.js")}).then(function() {
 | 
			
		||||
task.execute({name: "child.js", source: utf8Decode(File.readFile("child.js"))}).then(function() {
 | 
			
		||||
	print("child started");
 | 
			
		||||
});
 | 
			
		||||
EOF
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
cat > test.js << EOF
 | 
			
		||||
var task = new Task();
 | 
			
		||||
task.activate();
 | 
			
		||||
task.execute({name: "child.js", source: File.readFile("child.js")}).then(function() {
 | 
			
		||||
task.execute({name: "child.js", source: utf8Decode(File.readFile("child.js"))}).then(function() {
 | 
			
		||||
	task.getExports().then(function(exports) {
 | 
			
		||||
		return exports.add(1, 1);
 | 
			
		||||
	}).then(function(sum) {
 | 
			
		||||
 
 | 
			
		||||
@@ -3,15 +3,20 @@
 | 
			
		||||
cat > test.js << EOF
 | 
			
		||||
var task = new Task();
 | 
			
		||||
task.activate();
 | 
			
		||||
task.execute({name: "child.js", source: File.readFile("child.js")}).then(function() {
 | 
			
		||||
	task.getExports().then(function(exports) {
 | 
			
		||||
		return exports.add(1, 1);
 | 
			
		||||
task.execute({name: "child.js", source: utf8Decode(File.readFile("child.js"))}).then(function() {
 | 
			
		||||
	task.getExports().then(function(exp) {
 | 
			
		||||
		return exp.add(1, 1);
 | 
			
		||||
	}).then(function(sum) {
 | 
			
		||||
		exit(1);
 | 
			
		||||
	}).catch(function(error) {
 | 
			
		||||
		print("Caught: " + error.message);
 | 
			
		||||
		if (error.stack) {
 | 
			
		||||
			print("stack: " + error.stack);
 | 
			
		||||
		}
 | 
			
		||||
		exit(0);
 | 
			
		||||
	});
 | 
			
		||||
}).catch(function(e) {
 | 
			
		||||
	print("caught", e.message);
 | 
			
		||||
});
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
@@ -20,7 +25,7 @@ exports = {
 | 
			
		||||
	add: function(left, right) {
 | 
			
		||||
		throw new Error("fail");
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
};
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
$TILDEFRIENDS test.js
 | 
			
		||||
 
 | 
			
		||||
@@ -6,16 +6,16 @@ task.onExit = function() {
 | 
			
		||||
	print("child exited");
 | 
			
		||||
};
 | 
			
		||||
task.activate();
 | 
			
		||||
task.execute({name: "child.js", source: File.readFile("child.js")}).then(async function() {
 | 
			
		||||
task.execute({name: "child.js", source: utf8Decode(File.readFile("child.js"))}).then(async function() {
 | 
			
		||||
	print("child started");
 | 
			
		||||
	var input = new ArrayBuffer(10);
 | 
			
		||||
	var input = new Uint8Array(10);
 | 
			
		||||
	for (var i = 0; i < 10; i++) {
 | 
			
		||||
		input[i] = i;
 | 
			
		||||
	}
 | 
			
		||||
	var test = (await task.getExports()).test;
 | 
			
		||||
	var output = await test(input);
 | 
			
		||||
	print("input", input);
 | 
			
		||||
	print("output", output);
 | 
			
		||||
	var output = new Uint8Array(await test(input));
 | 
			
		||||
	print("input", input, input.length, input.byteLength);
 | 
			
		||||
	print("output", output, output.length, output.byteLength);
 | 
			
		||||
	for (var i = 0; i < 10; i++) {
 | 
			
		||||
		print(output[i]);
 | 
			
		||||
		if (output[i] != i) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										52
									
								
								tests/15-socket
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										52
									
								
								tests/15-socket
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
cat > test.js << EOF
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
var s = new Socket();
 | 
			
		||||
print("connecting");
 | 
			
		||||
print("before connect", s.isConnected);
 | 
			
		||||
s.onError(function(e) {
 | 
			
		||||
	print(e);
 | 
			
		||||
});
 | 
			
		||||
print("noDelay", s.noDelay);
 | 
			
		||||
s.noDelay = true;
 | 
			
		||||
s.connect("www.unprompted.com", 80).then(function() {
 | 
			
		||||
	print("connected", s.isConnected);
 | 
			
		||||
	print(s.peerName);
 | 
			
		||||
	s.read(function(data) {
 | 
			
		||||
		print("read", data.length);
 | 
			
		||||
	});
 | 
			
		||||
	s.write("GET / HTTP/1.0\r\n\r\n");
 | 
			
		||||
}).then(function() {
 | 
			
		||||
	print("closed");
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
var s2 = new Socket();
 | 
			
		||||
print("connecting");
 | 
			
		||||
print("before connect", s2.isConnected);
 | 
			
		||||
s2.onError(function(e) {
 | 
			
		||||
	print("error");
 | 
			
		||||
	print(e);
 | 
			
		||||
});
 | 
			
		||||
print("noDelay", s2.noDelay);
 | 
			
		||||
s2.noDelay = true;
 | 
			
		||||
s2.connect("www.unprompted.com", 443).then(function() {
 | 
			
		||||
	print("connected");
 | 
			
		||||
	s2.read(function(data) {
 | 
			
		||||
		print("read", data.length);
 | 
			
		||||
	});
 | 
			
		||||
	return s2.startTls();
 | 
			
		||||
}).then(function() {
 | 
			
		||||
	print("ready");
 | 
			
		||||
	print(s2.peerName);
 | 
			
		||||
	s2.write("GET / HTTP/1.0\r\nConnection: close\r\n\r\n").then(function() {
 | 
			
		||||
		s2.shutdown();
 | 
			
		||||
	});
 | 
			
		||||
}).catch(function(e) {
 | 
			
		||||
	printf("caught");
 | 
			
		||||
	print(e);
 | 
			
		||||
});
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
$TILDEFRIENDS test.js
 | 
			
		||||
		Reference in New Issue
	
	Block a user