From 8126076abae7dc1c256767077409427d8fad419c Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Sat, 18 May 2024 14:06:29 +0300 Subject: [PATCH 1/2] added test for NOMR mertic --- tests/metrics/test-ast.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/metrics/test-ast.sh b/tests/metrics/test-ast.sh index 81d48e8f..92f3b2dd 100755 --- a/tests/metrics/test-ast.sh +++ b/tests/metrics/test-ast.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# shellcheck disable=SC2317 # The MIT License (MIT) # # Copyright (c) 2021-2024 Yegor Bugayenko @@ -61,6 +62,8 @@ stdout=$2 grep "NOMPMx 0 " "${temp}/stdout" grep "NOSMPMx 0 " "${temp}/stdout" grep "NOM 0 " "${temp}/stdout" + # Uncomment it when the NOMR is implemented + # grep "NOMR 0 " "${temp}/stdout" grep "NOP 0 " "${temp}/stdout" grep "NULLs 0 " "${temp}/stdout" grep "DOER 0.5 " "${temp}/stdout" @@ -93,3 +96,20 @@ echo "👍🏻 Correctly counted NULL references" fi } > "${stdout}" 2>&1 echo "👍🏻 Usage works correctly" + + +# TODO: Remove this 'exit 0' below, uncomment the 'grep NOMR' above in first test and remove `shellcheck disable=SC2317` on the top when the NOMR is implemented +exit 0 +{ + java="${temp}/Hello.java" + echo "class Hello { + @Override + String x() { return null; } + String y() { return \"null\"; } + }" > "${java}" + "${LOCAL}/metrics/ast.py" "${java}" "${temp}/stdout" + cat "${temp}/stdout" + grep "NOM 2 " "${temp}/stdout" + grep "NOMR 0.5 " "${temp}/stdout" +} > "${stdout}" 2>&1 +echo "👍🏻 Correctly calculated NOM and NOMR" \ No newline at end of file From eb9b726545fbcba52b90f2d92f619a1582603d98 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Sat, 18 May 2024 14:10:09 +0300 Subject: [PATCH 2/2] specified the ticket for TODO --- tests/metrics/test-ast.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/metrics/test-ast.sh b/tests/metrics/test-ast.sh index 92f3b2dd..09719d4d 100755 --- a/tests/metrics/test-ast.sh +++ b/tests/metrics/test-ast.sh @@ -98,7 +98,7 @@ echo "👍🏻 Correctly counted NULL references" echo "👍🏻 Usage works correctly" -# TODO: Remove this 'exit 0' below, uncomment the 'grep NOMR' above in first test and remove `shellcheck disable=SC2317` on the top when the NOMR is implemented +# TODO: #316 Remove this 'exit 0' below, uncomment the 'grep NOMR' above in first test and remove `shellcheck disable=SC2317` on the top when the NOMR is implemented exit 0 { java="${temp}/Hello.java"