-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ class Metacall < Formula | |
head "https://github.com/metacall/core.git", branch: "develop" | ||
|
||
depends_on "cmake" => :build | ||
depends_on "node@18" | ||
depends_on "node@14" | ||
depends_on "openjdk" | ||
depends_on "[email protected]" | ||
depends_on "ruby" | ||
|
@@ -99,35 +99,49 @@ def install | |
Dir.mkdir(testpath/"typescript") | ||
(testpath/"typescript/typedfunc.ts").write <<~EOS | ||
'use strict'; | ||
export function typed_sum(left:number,right:number):number{return left+right} | ||
export async function typed_sum_async(left:number,right:number):Promise<number>{return left+right} | ||
export function build_name(first:string,last='Smith'){return`${first} ${last}`} | ||
export function object_pattern_ts({asd}){return asd} | ||
export function typed_array(a:number[]):number{return a[0]+a[1]+a[2]} | ||
export function object_record(a:Record<string, number>):number{return a.element} | ||
export function typed_sum(left: number, right: number): number { | ||
return left+right | ||
} | ||
export async function typed_sum_async(left: number, right: number): Promise<number> { | ||
return left+right | ||
} | ||
export function build_name(first: string, last = 'Smith') { | ||
return`${first} ${last}` | ||
} | ||
export function object_pattern_ts({asd}){ | ||
return asd | ||
} | ||
export function typed_array(a: number[]): number{ | ||
return a[0]+a[1]+a[2] | ||
} | ||
export function object_record(a: Record<string, number>): number { | ||
return a.element | ||
} | ||
EOS | ||
(testpath/"testTypescript.sh").write <<~EOS | ||
(testpath/"test_typescript.sh").write <<~EOS | ||
#!/usr/bin/env bash | ||
cd typescript | ||
echo 'load ts typedfunc.ts\ninspect\ncall typed_sum(4, 5)\nexit' | #{bin}/metacall | ||
EOS | ||
chmod("u+x", testpath/"testTypescript.sh") | ||
chmod("u+x", testpath/"test_typescript.sh") | ||
(testpath/"test.py").write <<~EOS | ||
print("Hello from Python") | ||
EOS | ||
(testpath/"test.rb").write <<~EOS | ||
print("Hello from Ruby") | ||
EOS | ||
(testpath/"test.java").write <<~EOS | ||
public class HelloWorld{public static void main(String[]args) | ||
{System.err.println("Hello from Java!");System.out.println("Hello from Java!"); | ||
System.out.println("Hello from Java!");System.out.println("Hello from Java!");}} | ||
public class test { | ||
public static void main(String[]args) { | ||
System.err.println("Hello from Java"); | ||
} | ||
} | ||
EOS | ||
# Tests | ||
assert_match "Hello from Python", shell_output("#{bin}/metacall test.py") | ||
assert_match "Hello from Ruby", shell_output("#{bin}/metacall test.rb") | ||
assert_match "Script (test.java) loaded correctly\n", shell_output("#{bin}/metacall test.java") | ||
assert_match "Hello from Java", shell_output("#{bin}/metacall test.java") | ||
assert_match "Hello from NodeJS", shell_output("#{bin}/metacall test.js") | ||
assert_match "9.0", shell_output(testpath/"testTypescript.sh") | ||
assert_match "9.0", shell_output(testpath/"test_typescript.sh") | ||
end | ||
end |