diff --git a/InitialArkTSCorpus/README.md b/InitialArkTSCorpus/README.md index fb69546d4d13b610a8790bbb6370f173da36c13a..860d8f68de5f5ab0b8c307bcdada87307820b040 100644 --- a/InitialArkTSCorpus/README.md +++ b/InitialArkTSCorpus/README.md @@ -1,12 +1,21 @@ -# How To Extend Initial ArkTS Corpus +# ArkTS Initial Corpus + +## How To Extend the Corpus This corpus is generated from ArkTS API examples: In order to extend the corpus please follow the steps: -1. Convert the given TypeScript code with the help from playground. Use import line so the compiler understands that you are using the API extension and is able to produce JavaScript code. +1. Convert the given TypeScript code with the help from playground. Use `import` line so the compiler understands that you are using the API extension and is able to produce JavaScript code. 2. Create a new `.js` file with this code in `InitialArkTSCorpus` folder. 3. Compile the given file to create corresponding `.fzil` program file (serialized `Program` class representation of FuzzIL program): `swift run FuzzILTool --compile ./InitialArkTSCorpus/.js` -4. Run fuzzing with importing of the initial ArkTS corpus. Provide the following options to FuzzilliCli: `--importCorpus=./InitialArkTSCorpus --corpusImportMode=full` -The full mode means you do not need to either assess or minimize the provided programs. They will be fed to mutators as is. +## How To Use the Corpus + +If you would like to limit your initial corpus to this one, then run fuzzing with importing of the initial ArkTS corpus. Provide the following options to FuzzilliCli: `--importCorpus=./InitialArkTSCorpus --corpusImportMode=full`. `Full` mode means you need neither to assess for usefulness nor to minimize the provided programs. They will be fed to mutators as is. These running options are also useful for testing your corpus while you are extending it. + +If you would like to use `GenerativeEngine` to generate more programs first then follow the next steps: + +1. Generate your initial corpus first by running the fuzzer with `--overwrite` option. +2. Copy the `InitalArkTSCorpus` content to your `corpus` folder where your generated programs are located. +3. Run the fuzzer with `--resume` option. diff --git a/InitialArkTSCorpus/hashMapClear.fzil b/InitialArkTSCorpus/hashMapClear.fzil new file mode 100644 index 0000000000000000000000000000000000000000..7343b1632b79fd32be01d66d893fc3ed56c42ba4 Binary files /dev/null and b/InitialArkTSCorpus/hashMapClear.fzil differ diff --git a/InitialArkTSCorpus/hashMapClear.js b/InitialArkTSCorpus/hashMapClear.js new file mode 100644 index 0000000000000000000000000000000000000000..05e9363f97c82af0a8fe20be1a4540c9931184bc --- /dev/null +++ b/InitialArkTSCorpus/hashMapClear.js @@ -0,0 +1,6 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +hashMap.clear(); \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapEntries.fzil b/InitialArkTSCorpus/hashMapEntries.fzil new file mode 100644 index 0000000000000000000000000000000000000000..a5726a9767f53c4adb5cbb75213973a162fa47f3 Binary files /dev/null and b/InitialArkTSCorpus/hashMapEntries.fzil differ diff --git a/InitialArkTSCorpus/hashMapEntries.js b/InitialArkTSCorpus/hashMapEntries.js new file mode 100644 index 0000000000000000000000000000000000000000..3bcf923bf2a57e846b456c2bc343c008a1248b79 --- /dev/null +++ b/InitialArkTSCorpus/hashMapEntries.js @@ -0,0 +1,12 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +let iter = hashMap.entries(); +let temp = iter.next(); +while (!temp.done) { + console.log("key:" + temp.value[0]); + console.log("value:" + temp.value[1]); + temp = iter.next(); +} \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapForEach.fzil b/InitialArkTSCorpus/hashMapForEach.fzil new file mode 100644 index 0000000000000000000000000000000000000000..774c73a63b6a9f6aaa1cf797b59178d378bfb9c7 Binary files /dev/null and b/InitialArkTSCorpus/hashMapForEach.fzil differ diff --git a/InitialArkTSCorpus/hashMapForEach.js b/InitialArkTSCorpus/hashMapForEach.js new file mode 100644 index 0000000000000000000000000000000000000000..d62c47acf6ba5fdc5f19a2cc045457111e40367c --- /dev/null +++ b/InitialArkTSCorpus/hashMapForEach.js @@ -0,0 +1,8 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("sparrow", 123); +hashMap.set("gull", 357); +hashMap.forEach((value, key) => { + console.log("value:" + value, "key:" + key); +}); \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapGet.fzil b/InitialArkTSCorpus/hashMapGet.fzil new file mode 100644 index 0000000000000000000000000000000000000000..057de3a257edf643228510a5703486a8c3fa8852 Binary files /dev/null and b/InitialArkTSCorpus/hashMapGet.fzil differ diff --git a/InitialArkTSCorpus/hashMapGet.js b/InitialArkTSCorpus/hashMapGet.js new file mode 100644 index 0000000000000000000000000000000000000000..6c88320b6baf2ee871209d8c65af64c27adcb296 --- /dev/null +++ b/InitialArkTSCorpus/hashMapGet.js @@ -0,0 +1,6 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +const hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +let result = hashMap.get("sparrow"); \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapHasKey.fzil b/InitialArkTSCorpus/hashMapHasKey.fzil new file mode 100644 index 0000000000000000000000000000000000000000..b49fbc6ad9ee6c2d434cdf85eb66e2786512d3e1 Binary files /dev/null and b/InitialArkTSCorpus/hashMapHasKey.fzil differ diff --git a/InitialArkTSCorpus/hashMapHasKey.js b/InitialArkTSCorpus/hashMapHasKey.js new file mode 100644 index 0000000000000000000000000000000000000000..48d511e591d22b3a38df3bfc405a141704a48eeb --- /dev/null +++ b/InitialArkTSCorpus/hashMapHasKey.js @@ -0,0 +1,5 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +const hashMap = new HashMap(); +hashMap.set("squirrel", 123); +let result = hashMap.hasKey("squirrel"); diff --git a/InitialArkTSCorpus/hashMapHasValue.fzil b/InitialArkTSCorpus/hashMapHasValue.fzil new file mode 100644 index 0000000000000000000000000000000000000000..5fd5743fcf85369022046ab60d708caa99eae808 Binary files /dev/null and b/InitialArkTSCorpus/hashMapHasValue.fzil differ diff --git a/InitialArkTSCorpus/hashMapHasValue.js b/InitialArkTSCorpus/hashMapHasValue.js new file mode 100644 index 0000000000000000000000000000000000000000..01a6ebfde886dd59f93550836bf57066fefab486 --- /dev/null +++ b/InitialArkTSCorpus/hashMapHasValue.js @@ -0,0 +1,5 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +const hashMap = new HashMap(); +hashMap.set("squirrel", 123); +let result = hashMap.hasValue(123); \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapIterator.fzil b/InitialArkTSCorpus/hashMapIterator.fzil new file mode 100644 index 0000000000000000000000000000000000000000..c244cb37f34028425a93d8babb97a9f47813cb29 Binary files /dev/null and b/InitialArkTSCorpus/hashMapIterator.fzil differ diff --git a/InitialArkTSCorpus/hashMapIterator.js b/InitialArkTSCorpus/hashMapIterator.js new file mode 100644 index 0000000000000000000000000000000000000000..30ed0980eaa92bb71692cb384fb15a824c70a809 --- /dev/null +++ b/InitialArkTSCorpus/hashMapIterator.js @@ -0,0 +1,19 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +// Method 1: +let keys = Array.from(hashMap.keys()); +for (let key of keys) { + console.log("key:" + key); + console.log("value:" + hashMap.get(key)); +} +// Method 2: +let iter = hashMap[Symbol.iterator](); +let temp = iter.next(); +while (!temp.done) { + console.log("key:" + temp.value[0]); + console.log("value:" + temp.value[1]); + temp = iter.next(); +} diff --git a/InitialArkTSCorpus/hashMapKeys.fzil b/InitialArkTSCorpus/hashMapKeys.fzil new file mode 100644 index 0000000000000000000000000000000000000000..0ae7509a6b0d64d06d1697b4b98a64a2ef12df03 Binary files /dev/null and b/InitialArkTSCorpus/hashMapKeys.fzil differ diff --git a/InitialArkTSCorpus/hashMapKeys.js b/InitialArkTSCorpus/hashMapKeys.js new file mode 100644 index 0000000000000000000000000000000000000000..b62b4bb8c5034bc536f599a6a6aed42187bb9224 --- /dev/null +++ b/InitialArkTSCorpus/hashMapKeys.js @@ -0,0 +1,11 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +let iter = hashMap.keys(); +let temp = iter.next(); +while (!temp.done) { + console.log("value:" + temp.value); + temp = iter.next(); +} \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapRemove.fzil b/InitialArkTSCorpus/hashMapRemove.fzil new file mode 100644 index 0000000000000000000000000000000000000000..7f6ce2003a9c5746343fbb484b317c9f889f4ac2 Binary files /dev/null and b/InitialArkTSCorpus/hashMapRemove.fzil differ diff --git a/InitialArkTSCorpus/hashMapRemove.js b/InitialArkTSCorpus/hashMapRemove.js new file mode 100644 index 0000000000000000000000000000000000000000..d3cd48fede31d6821b31dd2a28440506302f3f74 --- /dev/null +++ b/InitialArkTSCorpus/hashMapRemove.js @@ -0,0 +1,6 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +let result = hashMap.remove("sparrow"); \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapReplace.fzil b/InitialArkTSCorpus/hashMapReplace.fzil new file mode 100644 index 0000000000000000000000000000000000000000..f5583b7885ff14067365f6abeeb5489bb0cfaddb Binary files /dev/null and b/InitialArkTSCorpus/hashMapReplace.fzil differ diff --git a/InitialArkTSCorpus/hashMapReplace.js b/InitialArkTSCorpus/hashMapReplace.js new file mode 100644 index 0000000000000000000000000000000000000000..2a27dab9d3f08337288857e7a398a088f7d0e273 --- /dev/null +++ b/InitialArkTSCorpus/hashMapReplace.js @@ -0,0 +1,5 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("sparrow", 123); +let result = hashMap.replace("sparrow", 357); diff --git a/InitialArkTSCorpus/hashMapSet.fzil b/InitialArkTSCorpus/hashMapSet.fzil new file mode 100644 index 0000000000000000000000000000000000000000..bf1aaafde9d5a8fe38dfe76ed54e114ec565cb02 Binary files /dev/null and b/InitialArkTSCorpus/hashMapSet.fzil differ diff --git a/InitialArkTSCorpus/hashMapSet.js b/InitialArkTSCorpus/hashMapSet.js new file mode 100644 index 0000000000000000000000000000000000000000..eadbae6ea80af9e321e31d5382548f3cdf05604b --- /dev/null +++ b/InitialArkTSCorpus/hashMapSet.js @@ -0,0 +1,4 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +let result = hashMap.set("squirrel", 123); diff --git a/InitialArkTSCorpus/hashMapSetAll.fzil b/InitialArkTSCorpus/hashMapSetAll.fzil new file mode 100644 index 0000000000000000000000000000000000000000..c815cd3f24c84df6d393e6814d3714e6b31bdf77 Binary files /dev/null and b/InitialArkTSCorpus/hashMapSetAll.fzil differ diff --git a/InitialArkTSCorpus/hashMapSetAll.js b/InitialArkTSCorpus/hashMapSetAll.js new file mode 100644 index 0000000000000000000000000000000000000000..6f5973bb101da51f04eb82810e32912cfb8d2f08 --- /dev/null +++ b/InitialArkTSCorpus/hashMapSetAll.js @@ -0,0 +1,8 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +const hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +let newHashMap = new HashMap(); +newHashMap.set("newMap", 99); +hashMap.setAll(newHashMap); \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapValues.fzil b/InitialArkTSCorpus/hashMapValues.fzil new file mode 100644 index 0000000000000000000000000000000000000000..41f0ce9508dff57a007f67d0cd8a731a3029fc6c Binary files /dev/null and b/InitialArkTSCorpus/hashMapValues.fzil differ diff --git a/InitialArkTSCorpus/hashMapValues.js b/InitialArkTSCorpus/hashMapValues.js new file mode 100644 index 0000000000000000000000000000000000000000..8b8effa03a5fe4b9963254f24544d5c435ffd0ed --- /dev/null +++ b/InitialArkTSCorpus/hashMapValues.js @@ -0,0 +1,11 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +let iter = hashMap.values(); +let temp = iter.next(); +while (!temp.done) { + console.log("value:" + temp.value); + temp = iter.next(); +}