From 27bc69e837899e4d4c7f8bc31b5a0ddca74eea46 Mon Sep 17 00:00:00 2001 From: Mann Patel <130435633+Patel-Mann@users.noreply.github.com> Date: Wed, 17 Dec 2025 21:10:51 -0700 Subject: [PATCH] update: testing and result finding quest --- README.md | 149 +++++++++++++++++++++++++++++++++++++++++++--- tests/test1.java | 8 +++ tests/test10.java | 12 ++++ tests/test2.java | 11 ++++ tests/test3.java | 10 ++++ tests/test4.java | 13 ++++ tests/test5.java | 9 +++ tests/test6.java | 13 ++++ tests/test7.java | 11 ++++ tests/test8.java | 10 ++++ tests/test9.java | 10 ++++ 11 files changed, 249 insertions(+), 7 deletions(-) create mode 100644 tests/test1.java create mode 100644 tests/test10.java create mode 100644 tests/test2.java create mode 100644 tests/test3.java create mode 100644 tests/test4.java create mode 100644 tests/test5.java create mode 100644 tests/test6.java create mode 100644 tests/test7.java create mode 100644 tests/test8.java create mode 100644 tests/test9.java diff --git a/README.md b/README.md index 13e08b8..d573638 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,151 @@ -### Things -1. Forward Slice => All statements that could be affected if you change a given statement.Think of it like ripple effects in water: - - +## Termanology +1. Forward Slice => All statements that could be affected if you change a given statement. ### Run - ```bash chmod +x run.sh - # Show all dependencies for a file ./run.sh examples/Example1.java - # Analyze impact of line 3 ./run.sh examples/Example1.java 3 ``` + +# Testing +## Test1 simple data flow +### Line 3 (int x = 5;) +AIS = {3, 4, 5, 6} + +```bash +TODO: +``` + +### Line 4 (int y = x + 2;) +AIS = {4,5,6} + +```bash +=== Impact Analysis for Line 4 === + +Statement(s) at line 4: + 2: int y = x + 2 ; + +=== IMPACTED LINES === + Line 4 + Line 5 + Line 6 + +Total: 3 lines impacted +``` + + + + + +*** + +## Test2 Control Dependency +### Change at Line 5 (if (x > 5)) +AIS = {5, 6, 8, 9} + +```bash +=== Impact Analysis for Line 5 === + +Statement(s) at line 5: + 3: if ( x > 5 ) + +=== IMPACTED LINES === + Line 5 + Line 8 + Line 9 + +Total: 3 lines impacted +``` +TP: {5, 8, 9} |TP| = 3 +FP: {} |FP| = 0 +FN: {6} |FN| = 1 +Precision: 3 / (3 + 0) = 3/3 = 1.00 (100%) +Recall: 3 / (3 + 1) = 3/4 = 0.75 (75%) +Analysis: +- Perfect precision (no false alarms) +- Missed line 6 (the assignment inside the if-block) +- UNDER-APPROXIMATION + +### Change at Line 3 (int x = 10;) +AIS = {3, 5, 6, 8, 9} + +*** + +## Test3 Simple Loop +### Change at Line 3 (int sum = 0;) +AIS = {3, 6, 8} + +### Change at Line 5 (for loop heading) +AIS = {5, 6, 8} + +*** + +## Test4 If-Else Branch +### Change at Line 5 (if (x > 5)) +AIS = {5, 6, 8, 10, 11} + +### Change at Line 6 (y = x + 10;) +AIS = {6, 10, 11} + +*** + +## Test5 Multiple Uses va +### Change at Line 3 (int a = 5;) +AIS = {3, 4, 5, 6, 7} + +### Change at Line 4 (int b = a + 2;) +AIS = {4, 6, 7} + +*** + +## Test6 Nested Control +### Change at Line 5 (if (x > 5)) +AIS = {5, 6, 7, 10, 11} + +### Change at Line 6 (if (x > 8)) +AIS = {6, 7, 10, 11} + +*** + +## Test7 While Loop +### Change at Line 5 (while (count < 5)) +AIS = {5, 6, 7, 9} + +### Change at Line 3 (int count = 0;) +AIS = {3, 5, 6, 7, 9} + +*** + +## Test8 Reassignment +### Change at Line 3 (int x = 5;) +AIS = {3, 4, 7} + +### Change at Line 5 (x = 10;) +AIS = {5, 6, 8} + +*** + +## Test9 No Impact +### Change at Line 4 (int y = 10;) +AIS = {4, 6, 8} + +### Change at Line 3 (int x = 5;) +AIS = {3, 5, 7} + +*** + +## Test10 Complex Expression +### Change at Line 3 (int a = 2;) +AIS = {3, 6, 7, 8, 9} + +### Change at Line 8 (if (x > 5)) +AIS = {8, 9} + +```bash +=== IMPACTED LINES === + Line 6 + Line 8 +``` diff --git a/tests/test1.java b/tests/test1.java new file mode 100644 index 0000000..1f240cc --- /dev/null +++ b/tests/test1.java @@ -0,0 +1,8 @@ +public class test1 { + public static void main(String[] args) { + int x = 5; // Line 3 + int y = x + 2; // Line 4 + int z = y * 3; // Line 5 + System.out.println(z); // Line 6 + } +} diff --git a/tests/test10.java b/tests/test10.java new file mode 100644 index 0000000..e7e72aa --- /dev/null +++ b/tests/test10.java @@ -0,0 +1,12 @@ +public class test10{ + public static void main(String[] args) { + int a = 2; // Line 3 + int b = 3; // Line 4 + int c = 4; // Line 5 + int result = (a + b) * c; // Line 6 + int x = result / 2; // Line 7 + if (x > 5) { // Line 8 + System.out.println(x); // Line 9 + } + } +} diff --git a/tests/test2.java b/tests/test2.java new file mode 100644 index 0000000..7d11c56 --- /dev/null +++ b/tests/test2.java @@ -0,0 +1,11 @@ +public class test2{ + public static void main(String[] args) { + int x = 10; // Line 3 + int y = 0; // Line 4 + if (x > 5) { // Line 5 + y = x * 2; // Line 6 + } + int z = y + 1; // Line 8 + System.out.println(z); // Line 9 + } +} diff --git a/tests/test3.java b/tests/test3.java new file mode 100644 index 0000000..a7a038b --- /dev/null +++ b/tests/test3.java @@ -0,0 +1,10 @@ +public class test3 { + public static void main(String[] args) { + int sum = 0; // Line 3 + int i; // Line 4 + for (i = 0; i < 5; i++) { // Line 5 + sum = sum + i; // Line 6 + } + System.out.println(sum); // Line 8 + } +} diff --git a/tests/test4.java b/tests/test4.java new file mode 100644 index 0000000..f90d5f9 --- /dev/null +++ b/tests/test4.java @@ -0,0 +1,13 @@ +public class test4{ + public static void main(String[] args) { + int x = 10; // Line 3 + int y = 0; // Line 4 + if (x > 5) { // Line 5 + y = x + 10; // Line 6 + } else { + y = x - 10; // Line 8 + } + int z = y * 2; // Line 10 + System.out.println(z); // Line 11 + } +} diff --git a/tests/test5.java b/tests/test5.java new file mode 100644 index 0000000..a17394a --- /dev/null +++ b/tests/test5.java @@ -0,0 +1,9 @@ +public class test5 { + public static void main(String[] args) { + int a = 5; // Line 3 + int b = a + 2; // Line 4 + int c = a * 3; // Line 5 + int d = b + c; // Line 6 + System.out.println(d); // Line 7 + } +} diff --git a/tests/test6.java b/tests/test6.java new file mode 100644 index 0000000..829f56e --- /dev/null +++ b/tests/test6.java @@ -0,0 +1,13 @@ +public class test6{ + public static void main(String[] args) { + int x = 10; // Line 3 + int y = 0; // Line 4 + if (x > 5) { // Line 5 + if (x > 8) { // Line 6 + y = x * 2; // Line 7 + } + } + int z = y + 1; // Line 10 + System.out.println(z); // Line 11 + } +} diff --git a/tests/test7.java b/tests/test7.java new file mode 100644 index 0000000..7f86026 --- /dev/null +++ b/tests/test7.java @@ -0,0 +1,11 @@ +public class test7 { + public static void main(String[] args) { + int count = 0; // Line 3 + int sum = 0; // Line 4 + while (count < 5) { // Line 5 + sum = sum + count; // Line 6 + count = count + 1; // Line 7 + } + System.out.println(sum); // Line 9 + } +} diff --git a/tests/test8.java b/tests/test8.java new file mode 100644 index 0000000..f12c7a7 --- /dev/null +++ b/tests/test8.java @@ -0,0 +1,10 @@ +public class test8 { + public static void main(String[] args) { + int x = 5; // Line 3 + int y = x + 1; // Line 4 + x = 10; // Line 5 + int z = x * 2; // Line 6 + System.out.println(y); // Line 7 + System.out.println(z); // Line 8 + } +} diff --git a/tests/test9.java b/tests/test9.java new file mode 100644 index 0000000..f03fa54 --- /dev/null +++ b/tests/test9.java @@ -0,0 +1,10 @@ +public class test9{ + public static void main(String[] args) { + int x = 5; // Line 3 + int y = 10; // Line 4 + int z = x + 1; // Line 5 + int w = y + 2; // Line 6 + System.out.println(z); // Line 7 + System.out.println(w); // Line 8 + } +}