I stumble across a lot of interesting JavaScript resources (articles, tutorials, videos, etc.) day to day. Many I don't have time to read, at least not right away, so I am dumping them here. Some of these resources might suck, so bear with me.
Testing JavaScript isn't just a thing you can read about in children's fairy tales.
This is just a scratch pad of everything I find. As the really good resources start to float to the top, I'll transition them to a more permanent GitHub repo.
- Test-Driven JavaScript Development [book]
- JavaScript Testing Recipes [book]
This file contains hidden or 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
public class ItemPrinter { | |
public static void printItem(Integer i) { | |
System.out.println(i.toString()); | |
} | |
public static void printItem(String s) { | |
System.out.println(s); | |
} | |
} |
This file contains hidden or 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
import java.util.List; | |
public class ListPrinter { | |
public static void printList(List<Integer> list) { | |
for(Integer i : list) { | |
System.out.println(i.toString()); | |
} | |
} | |
This file contains hidden or 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
import java.util.List; | |
public class GenericsErasure { | |
public static void main(String[] args) { | |
//... | |
} | |
public static void printList(List list) { | |
//... |
This file contains hidden or 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
# Some commands from using Soot on the command-line | |
# First, put the Soot jars on your Java CLASSPATH (preferrably through .bashrc or .zshrc) | |
export SOOTJAR=path/to/sootclasses-2.5.0.jar | |
export JASMINJAR=path/to/jasminclasses-2.5.0.jar | |
export POLYGLOTJAR=path/to/polyglotclasses-1.3.5.jar | |
export CLASSPATH=$SOOTJAR:$JASMINJAR:$POLYGLOTJAR:$CLASSPATH | |
# Using Soot to compile a single Java file: | |
# +-project/ |
This file contains hidden or 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
/* | |
* We are given 3 arrays a,b,c of integers sorted in ascending order, and we are told | |
* that there is a value that occurs in all three arrays. Write a Dafny program to | |
* compute the index in each array where the common value occurs. | |
* | |
* This is the best implementation I can come up with for this problem, however it | |
* is still not verifiable by Dafny. It is a combination of the loop invariants or | |
* ensures that seem to fail based on various permutations of saying that p,q,r are | |
* < or <= a.Length,b.Length,c.Length, respectively. The long requires statement and | |
* the identical assume statement have been added to keep the previously mentioned |
This file contains hidden or 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
method find(A:array<int>, key: int) returns (k:int) | |
requires A != null && A.Length > 0 ; | |
requires A[0] < A[A.Length-1] ; | |
ensures 0 <= k < A.Length-1 ; | |
ensures A[k] < A[k+1] ; | |
{ | |
var i:int := 0; | |
while(i < A.length) { | |
if(A[i] == key) { | |
return i; |
This file contains hidden or 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
function method Fibonacci(n: int): int | |
requires n >= 0; | |
decreases n; | |
{ | |
if n < 2 then n else Fibonacci(n-2) + Fibonacci(n-1) | |
} | |
method Testing() { | |
assert 0 == Fibonacci(0); | |
assert 1 == Fibonacci(1); |