diff --git a/.bazelrc b/.bazelrc index ebcb2f1fcdd..f988dcc364a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -6,5 +6,13 @@ build --android_databinding_use_v3_4_args \ --define=android_standalone_dexing_tool=d8_compat_dx \ --android_databinding_use_androidx +# Ensure all built Java files treat warnings as errors (similar to the Kotlin configuration) to help +# reduce code smell & potential bugs during development. +build --javacopt="-Werror" + +# Note that this doesn't stop 'Werror' from being passed above, but that shouldn't affect most of +# the Oppia Android-specific build. +build:ignore_build_warnings --//tools/kotlin:warn_mode=warning + # Show all test output by default (for better debugging). test --test_output=all diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b4a1de1c04a..d2c51eaa7e2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -250,6 +250,7 @@ WORKSPACE @oppia/android-app-infrastructure-reviewers .bazelrc @oppia/android-app-infrastructure-reviewers .bazelversion @oppia/android-app-infrastructure-reviewers /tools/android/ @oppia/android-app-infrastructure-reviewers +/tools/kotlin/ @oppia/android-app-infrastructure-reviewers # Configurations for Bazel-built Android App Bundles. /bundle_config.pb.json @oppia/android-dev-workflow-reviewers diff --git a/WORKSPACE b/WORKSPACE index 0ee7cf91146..dc4b29ece77 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -42,17 +42,22 @@ http_archive( # Add support for Kotlin: https://github.com/bazelbuild/rules_kotlin. http_archive( name = "io_bazel_rules_kotlin", + patches = ["//tools/kotlin:add_kotlinc_optin_support.patch"], sha256 = HTTP_DEPENDENCY_VERSIONS["rules_kotlin"]["sha"], urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/%s/rules_kotlin_release.tgz" % HTTP_DEPENDENCY_VERSIONS["rules_kotlin"]["version"]], ) -load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories") +load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "kotlinc_version") -kotlin_repositories() - -load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains") +# Use the 1.6 compiler since rules_kotlin 1.5 defaults to the 1.5 compiler. +kotlin_repositories( + compiler_release = kotlinc_version( + release = "1.6.10", + sha256 = "432267996d0d6b4b17ca8de0f878e44d4a099b7e9f1587a98edc4d27e76c215a", + ), +) -kt_register_toolchains() +register_toolchains("//tools/kotlin:kotlin_16_jdk9_toolchain") # The proto_compiler and proto_java_toolchain bindings load the protos rules needed for the model # module while helping us avoid the unnecessary compilation of protoc. Referecences: @@ -141,18 +146,18 @@ git_repository( git_repository( name = "android-spotlight", - commit = "ebde38335bfb56349eae57e705b611ead9addb15", + commit = "cc23499d37dc8533a2876e45b5063e981a4583f4", remote = "https://github.com/oppia/android-spotlight", - shallow_since = "1668824029 -0800", + shallow_since = "1680147372 -0700", ) # A custom fork of KotliTeX that removes resources artifacts that break the build, and updates the # min target SDK version to be compatible with Oppia. git_repository( name = "kotlitex", - commit = "43139c140833c7120f351d63d74b42c253d2b213", + commit = "ccdf4170817fa3b48b8e1e452772dd58ecb71cf2", remote = "https://github.com/oppia/kotlitex", - shallow_since = "1675741075 -0800", + shallow_since = "1679426649 -0700", ) bind( @@ -199,6 +204,7 @@ maven_install( maven_install_json = "//third_party:maven_install.json", override_targets = { "com.google.guava:guava": "@//third_party:com_google_guava_guava", + "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm": "@//third_party:kotlinx-coroutines-core-jvm", }, repositories = DAGGER_REPOSITORIES + MAVEN_REPOSITORIES, strict_visibility = True, @@ -219,3 +225,15 @@ http_jar( for url_base in DAGGER_REPOSITORIES + MAVEN_REPOSITORIES ], ) + +http_jar( + name = "kotlinx-coroutines-core-jvm", + sha256 = HTTP_DEPENDENCY_VERSIONS["kotlinx-coroutines-core-jvm"]["sha"], + urls = [ + "{0}/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/{1}/kotlinx-coroutines-core-jvm-{1}.jar".format( + url_base, + HTTP_DEPENDENCY_VERSIONS["kotlinx-coroutines-core-jvm"]["version"], + ) + for url_base in DAGGER_REPOSITORIES + MAVEN_REPOSITORIES + ], +) diff --git a/app/build.gradle b/app/build.gradle index 2e5168ccd1c..34a996bfce2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -147,7 +147,6 @@ if (project.gradle.startParameter?.taskRequests?.args[0]?.remove("--list-shards" dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation( - 'android.arch.lifecycle:extensions:1.1.1', 'androidx.appcompat:appcompat:1.0.2', 'androidx.constraintlayout:constraintlayout:1.1.3', 'androidx.core:core-ktx:1.0.2', @@ -166,7 +165,7 @@ dependencies { 'com.github.bumptech.glide:glide:4.11.0', 'com.google.android.flexbox:flexbox:3.0.0', 'com.google.android.material:material:1.3.0', - 'com.google.dagger:dagger:2.24', + 'com.google.dagger:dagger:2.41', 'com.google.firebase:firebase-analytics:17.5.0', 'com.google.firebase:firebase-analytics-ktx:17.5.0', 'com.google.firebase:firebase-appcheck:16.0.0', @@ -180,10 +179,10 @@ dependencies { 'com.google.protobuf:protobuf-javalite:3.17.3', 'nl.dionsegijn:konfetti:1.2.5', "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version", - 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1', - 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1', + 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4', + 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4', 'org.mockito:mockito-core:2.7.22', - 'com.github.oppia:android-spotlight:ebde38335bfb56349eae57e705b611ead9addb15' + 'com.github.oppia:android-spotlight:cc23499d37dc8533a2876e45b5063e981a4583f4' ) compileOnly( 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.2', @@ -203,7 +202,7 @@ dependencies { 'com.google.truth.extensions:truth-liteproto-extension:1.1.3', 'org.robolectric:annotations:4.5', 'org.robolectric:robolectric:4.5', - 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2', + 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4', "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version", 'org.mockito:mockito-core:2.7.22', project(":testing"), @@ -219,7 +218,7 @@ dependencies { 'com.google.truth:truth:1.1.3', 'androidx.work:work-testing:2.4.0', 'com.google.truth.extensions:truth-liteproto-extension:1.1.3', - 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2', + 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4', 'org.mockito:mockito-android:2.7.22', 'org.robolectric:annotations:4.5', ) @@ -243,13 +242,13 @@ dependencies { 'androidx.test:orchestrator:1.2.0', ) kapt( - 'com.google.dagger:dagger-compiler:2.24' + 'com.google.dagger:dagger-compiler:2.41' ) kaptTest( - 'com.google.dagger:dagger-compiler:2.24' + 'com.google.dagger:dagger-compiler:2.41' ) kaptAndroidTest( - 'com.google.dagger:dagger-compiler:2.24' + 'com.google.dagger:dagger-compiler:2.41' ) // TODO(#59): Remove this once Bazel is introduced api project(':data') diff --git a/app/src/main/java/org/oppia/android/app/translation/AppLanguageResourceHandler.kt b/app/src/main/java/org/oppia/android/app/translation/AppLanguageResourceHandler.kt index fed7674f823..05ad59fac13 100644 --- a/app/src/main/java/org/oppia/android/app/translation/AppLanguageResourceHandler.kt +++ b/app/src/main/java/org/oppia/android/app/translation/AppLanguageResourceHandler.kt @@ -191,6 +191,8 @@ class AppLanguageResourceHandler @Inject constructor( private fun getLocalizedDisplayName(languageCode: String, regionCode: String = ""): String { // TODO(#3791): Remove this dependency. val locale = Locale(languageCode, regionCode) - return locale.getDisplayLanguage(locale).capitalize(locale) + return locale.getDisplayLanguage(locale).replaceFirstChar { + if (it.isLowerCase()) it.titlecase(locale) else it.toString() + } } } diff --git a/app/src/main/java/org/oppia/android/app/viewmodel/BUILD.bazel b/app/src/main/java/org/oppia/android/app/viewmodel/BUILD.bazel index eafd028c412..aad83fb54ce 100644 --- a/app/src/main/java/org/oppia/android/app/viewmodel/BUILD.bazel +++ b/app/src/main/java/org/oppia/android/app/viewmodel/BUILD.bazel @@ -23,6 +23,5 @@ kt_android_library( visibility = ["//visibility:public"], deps = [ "//third_party:androidx_databinding_databinding-adapters", - "//third_party:androidx_lifecycle_lifecycle-extensions", ], ) diff --git a/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt b/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt index d49c45732b6..68ed0efe096 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/customview/interaction/MathExpressionInteractionsViewTest.kt @@ -86,7 +86,6 @@ import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedAutoAndroidTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -172,15 +171,13 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration( - "numeric_exp", - "type=NUMERIC_EXPRESSION", - "expHintText=Type an expression here, using only numbers." - ), - Iteration("alg_exp", "type=ALGEBRAIC_EXPRESSION", "expHintText=Type an expression here."), - Iteration("math_equation", "type=MATH_EQUATION", "expHintText=Type an equation here.") + @Iteration( + "numeric_exp", + "type=NUMERIC_EXPRESSION", + "expHintText=Type an expression here, using only numbers." ) + @Iteration("alg_exp", "type=ALGEBRAIC_EXPRESSION", "expHintText=Type an expression here.") + @Iteration("math_equation", "type=MATH_EQUATION", "expHintText=Type an equation here.") fun testView_allInteractions_withoutPlaceholder_hasCorrectDefaultHintText() { launch(interactionType = MathInteractionType.valueOf(type)).use { testCoroutineDispatchers.runCurrent() @@ -202,10 +199,8 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("alg_exp", "type=ALGEBRAIC_EXPRESSION", "expHintText=Type an expression here."), - Iteration("math_equation", "type=MATH_EQUATION", "expHintText=Type an equation here.") - ) + @Iteration("alg_exp", "type=ALGEBRAIC_EXPRESSION", "expHintText=Type an expression here.") + @Iteration("math_equation", "type=MATH_EQUATION", "expHintText=Type an equation here.") fun testView_algebraicInteractions_withUnicodePlaceholder_hasDefaultHintText() { val interaction = createInteractionWithPlaceholder("test placeholder") launch(interactionType = MathInteractionType.valueOf(type), interaction).use { @@ -229,10 +224,8 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("alg_exp", "type=ALGEBRAIC_EXPRESSION", "expHintText=Type an expression here."), - Iteration("math_equation", "type=MATH_EQUATION", "expHintText=Type an equation here.") - ) + @Iteration("alg_exp", "type=ALGEBRAIC_EXPRESSION", "expHintText=Type an expression here.") + @Iteration("math_equation", "type=MATH_EQUATION", "expHintText=Type an equation here.") fun testView_algebraicInteractions_withNestedUnicodePlaceholder_hasDefaultHintText() { val interaction = createInteractionWithNestedPlaceholder("test placeholder") launch(interactionType = MathInteractionType.valueOf(type), interaction).use { @@ -415,32 +408,30 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_-1", "type=NUMERIC_EXPRESSION", "text= - 1 "), - Iteration("numeric_1+2", "type=NUMERIC_EXPRESSION", "text=1 + 2"), - Iteration("numeric_1-2", "type=NUMERIC_EXPRESSION", "text=1 − 2"), - Iteration("numeric_1*2", "type=NUMERIC_EXPRESSION", "text=1 × 2"), - Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1 ÷ 2"), - Iteration("numeric_long_exp", "type=NUMERIC_EXPRESSION", "text=3*2-3+4^3*8/3*2+7"), - Iteration("numeric_invalid_exp_extra_error", "type=NUMERIC_EXPRESSION", "text=3/0"), - Iteration("numeric_invalid_exp_syntax_error", "type=NUMERIC_EXPRESSION", "text=3!"), - Iteration("algebraic_-1", "type=ALGEBRAIC_EXPRESSION", "text= - x "), - Iteration("algebraic_1+2", "type=ALGEBRAIC_EXPRESSION", "text=x + 2"), - Iteration("algebraic_1-2", "type=ALGEBRAIC_EXPRESSION", "text=x − 2"), - Iteration("algebraic_1*2", "type=ALGEBRAIC_EXPRESSION", "text=x × 2"), - Iteration("algebraic_1/2", "type=ALGEBRAIC_EXPRESSION", "text=x c 2"), - Iteration("algebraic_long_exp", "type=ALGEBRAIC_EXPRESSION", "text=12x^2y^2-(yz^2+yzx)-731z"), - Iteration("algebraic_invalid_exp_extra_error", "type=ALGEBRAIC_EXPRESSION", "text=2^x"), - Iteration("algebraic_invalid_exp_syntax_error", "type=ALGEBRAIC_EXPRESSION", "text=2**x"), - Iteration("math_eq_-1", "type=MATH_EQUATION", "text= y= - x "), - Iteration("math_eq_1+2", "type=MATH_EQUATION", "text=y = x + 2"), - Iteration("math_eq_1-2", "type=MATH_EQUATION", "text=y = x − 2"), - Iteration("math_eq_1*2", "type=MATH_EQUATION", "text=y = x × 2"), - Iteration("math_eq_1/2", "type=MATH_EQUATION", "text=y = x ÷ 2"), - Iteration("math_eq_long_exp", "type=MATH_EQUATION", "text=(x^2-1)/(x+1)=y/2"), - Iteration("math_eq_invalid_exp_extra_error", "type=MATH_EQUATION", "text=y=+x"), - Iteration("math_eq_invalid_exp_syntax_error", "type=MATH_EQUATION", "text=y=x=z") - ) + @Iteration("numeric_-1", "type=NUMERIC_EXPRESSION", "text= - 1 ") + @Iteration("numeric_1+2", "type=NUMERIC_EXPRESSION", "text=1 + 2") + @Iteration("numeric_1-2", "type=NUMERIC_EXPRESSION", "text=1 − 2") + @Iteration("numeric_1*2", "type=NUMERIC_EXPRESSION", "text=1 × 2") + @Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1 ÷ 2") + @Iteration("numeric_long_exp", "type=NUMERIC_EXPRESSION", "text=3*2-3+4^3*8/3*2+7") + @Iteration("numeric_invalid_exp_extra_error", "type=NUMERIC_EXPRESSION", "text=3/0") + @Iteration("numeric_invalid_exp_syntax_error", "type=NUMERIC_EXPRESSION", "text=3!") + @Iteration("algebraic_-1", "type=ALGEBRAIC_EXPRESSION", "text= - x ") + @Iteration("algebraic_1+2", "type=ALGEBRAIC_EXPRESSION", "text=x + 2") + @Iteration("algebraic_1-2", "type=ALGEBRAIC_EXPRESSION", "text=x − 2") + @Iteration("algebraic_1*2", "type=ALGEBRAIC_EXPRESSION", "text=x × 2") + @Iteration("algebraic_1/2", "type=ALGEBRAIC_EXPRESSION", "text=x c 2") + @Iteration("algebraic_long_exp", "type=ALGEBRAIC_EXPRESSION", "text=12x^2y^2-(yz^2+yzx)-731z") + @Iteration("algebraic_invalid_exp_extra_error", "type=ALGEBRAIC_EXPRESSION", "text=2^x") + @Iteration("algebraic_invalid_exp_syntax_error", "type=ALGEBRAIC_EXPRESSION", "text=2**x") + @Iteration("math_eq_-1", "type=MATH_EQUATION", "text= y= - x ") + @Iteration("math_eq_1+2", "type=MATH_EQUATION", "text=y = x + 2") + @Iteration("math_eq_1-2", "type=MATH_EQUATION", "text=y = x − 2") + @Iteration("math_eq_1*2", "type=MATH_EQUATION", "text=y = x × 2") + @Iteration("math_eq_1/2", "type=MATH_EQUATION", "text=y = x ÷ 2") + @Iteration("math_eq_long_exp", "type=MATH_EQUATION", "text=(x^2-1)/(x+1)=y/2") + @Iteration("math_eq_invalid_exp_extra_error", "type=MATH_EQUATION", "text=y=+x") + @Iteration("math_eq_invalid_exp_syntax_error", "type=MATH_EQUATION", "text=y=x=z") fun testView_allInteractions_differentAnswers_producesAnswerWithOriginalMathExpression() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() @@ -459,40 +450,38 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_-1", "type=NUMERIC_EXPRESSION", "text= - 1 ", "expLatex=-1"), - Iteration("numeric_1+2", "type=NUMERIC_EXPRESSION", "text=1 + 2", "expLatex=1 + 2"), - Iteration("numeric_1-2", "type=NUMERIC_EXPRESSION", "text=1 − 2", "expLatex=1 - 2"), - Iteration("numeric_1*2", "type=NUMERIC_EXPRESSION", "text=1 × 2", "expLatex=1 \\times 2"), - Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1 ÷ 2", "expLatex=1 \\div 2"), - Iteration( - "numeric_long_exp", - "type=NUMERIC_EXPRESSION", - "text=3*2-3+4^3*8/3*2+7", - "expLatex=3 \\times 2 - 3 + 4 ^ {3} \\times 8 \\div 3 \\times 2 + 7" - ), - Iteration("algebraic_-x", "type=ALGEBRAIC_EXPRESSION", "text= - x ", "expLatex=-x"), - Iteration("algebraic_x+2", "type=ALGEBRAIC_EXPRESSION", "text=x + 2", "expLatex=x + 2"), - Iteration("algebraic_x-2", "type=ALGEBRAIC_EXPRESSION", "text=x − 2", "expLatex=x - 2"), - Iteration("algebraic_x*2", "type=ALGEBRAIC_EXPRESSION", "text=x × 2", "expLatex=x \\times 2"), - Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x ÷ 2", "expLatex=x \\div 2"), - Iteration( - "algebraic_long_exp", - "type=ALGEBRAIC_EXPRESSION", - "text=12x^2y^2-(yz^2+yzx)-731z", - "expLatex=12x ^ {2}y ^ {2} - (yz ^ {2} + yzx) - 731z" - ), - Iteration("math_eq_-x", "type=MATH_EQUATION", "text= y= - x ", "expLatex=y = -x"), - Iteration("math_eq_x+2", "type=MATH_EQUATION", "text=y = x + 2", "expLatex=y = x + 2"), - Iteration("math_eq_x-2", "type=MATH_EQUATION", "text=y = x − 2", "expLatex=y = x - 2"), - Iteration("math_eq_x*2", "type=MATH_EQUATION", "text=y = x × 2", "expLatex=y = x \\times 2"), - Iteration("math_eq_x/2", "type=MATH_EQUATION", "text=y = x ÷ 2", "expLatex=y = x \\div 2"), - Iteration( - "math_eq_long_exp", - "type=MATH_EQUATION", - "text=(x^2-1)/(x+1)=y/2", - "expLatex=(x ^ {2} - 1) \\div (x + 1) = y \\div 2" - ) + @Iteration("numeric_-1", "type=NUMERIC_EXPRESSION", "text= - 1 ", "expLatex=-1") + @Iteration("numeric_1+2", "type=NUMERIC_EXPRESSION", "text=1 + 2", "expLatex=1 + 2") + @Iteration("numeric_1-2", "type=NUMERIC_EXPRESSION", "text=1 − 2", "expLatex=1 - 2") + @Iteration("numeric_1*2", "type=NUMERIC_EXPRESSION", "text=1 × 2", "expLatex=1 \\times 2") + @Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1 ÷ 2", "expLatex=1 \\div 2") + @Iteration( + "numeric_long_exp", + "type=NUMERIC_EXPRESSION", + "text=3*2-3+4^3*8/3*2+7", + "expLatex=3 \\times 2 - 3 + 4 ^ {3} \\times 8 \\div 3 \\times 2 + 7" + ) + @Iteration("algebraic_-x", "type=ALGEBRAIC_EXPRESSION", "text= - x ", "expLatex=-x") + @Iteration("algebraic_x+2", "type=ALGEBRAIC_EXPRESSION", "text=x + 2", "expLatex=x + 2") + @Iteration("algebraic_x-2", "type=ALGEBRAIC_EXPRESSION", "text=x − 2", "expLatex=x - 2") + @Iteration("algebraic_x*2", "type=ALGEBRAIC_EXPRESSION", "text=x × 2", "expLatex=x \\times 2") + @Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x ÷ 2", "expLatex=x \\div 2") + @Iteration( + "algebraic_long_exp", + "type=ALGEBRAIC_EXPRESSION", + "text=12x^2y^2-(yz^2+yzx)-731z", + "expLatex=12x ^ {2}y ^ {2} - (yz ^ {2} + yzx) - 731z" + ) + @Iteration("math_eq_-x", "type=MATH_EQUATION", "text= y= - x ", "expLatex=y = -x") + @Iteration("math_eq_x+2", "type=MATH_EQUATION", "text=y = x + 2", "expLatex=y = x + 2") + @Iteration("math_eq_x-2", "type=MATH_EQUATION", "text=y = x − 2", "expLatex=y = x - 2") + @Iteration("math_eq_x*2", "type=MATH_EQUATION", "text=y = x × 2", "expLatex=y = x \\times 2") + @Iteration("math_eq_x/2", "type=MATH_EQUATION", "text=y = x ÷ 2", "expLatex=y = x \\div 2") + @Iteration( + "math_eq_long_exp", + "type=MATH_EQUATION", + "text=(x^2-1)/(x+1)=y/2", + "expLatex=(x ^ {2} - 1) \\div (x + 1) = y \\div 2" ) fun testView_allInteractions_differentAnswers_validAnswers_producesAnswerWithLatexHtml() { val interactionType = MathInteractionType.valueOf(type) @@ -514,37 +503,35 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1/2", "expLatex=1 \\div 2"), - Iteration( - "numeric_1/2/3", "type=NUMERIC_EXPRESSION", "text=1/2/3", "expLatex=1 \\div 2 \\div 3" - ), - Iteration( - "numeric_1/(2+3)", "type=NUMERIC_EXPRESSION", "text=1/(2+3)", "expLatex=1 \\div (2 + 3)" - ), - Iteration("numeric_1/2+3", "type=NUMERIC_EXPRESSION", "text=1/2+3", "expLatex=1 \\div 2 + 3"), - Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x/2", "expLatex=x \\div 2"), - Iteration( - "algebraic_x/y/z", "type=ALGEBRAIC_EXPRESSION", "text=x/y/z", "expLatex=x \\div y \\div z" - ), - Iteration( - "algebraic_x/(2+y)", "type=ALGEBRAIC_EXPRESSION", "text=x/(2+y)", "expLatex=x \\div (2 + y)" - ), - Iteration( - "algebraic_x/2+y", "type=ALGEBRAIC_EXPRESSION", "text=x/2+y", "expLatex=x \\div 2 + y" - ), - Iteration("math_eq_x/2", "type=MATH_EQUATION", "text=y=x/2", "expLatex=y = x \\div 2"), - Iteration( - "math_eq_x/y/z", - "type=MATH_EQUATION", - "text=y/2=x/y/z", - "expLatex=y \\div 2 = x \\div y \\div z" - ), - Iteration( - "math_eq_x/(2+y)", "type=MATH_EQUATION", "text=x/(2+y)=y", "expLatex=x \\div (2 + y) = y" - ), - Iteration("math_eq_x/2+y", "type=MATH_EQUATION", "text=x/2+y=y", "expLatex=x \\div 2 + y = y") + @Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1/2", "expLatex=1 \\div 2") + @Iteration( + "numeric_1/2/3", "type=NUMERIC_EXPRESSION", "text=1/2/3", "expLatex=1 \\div 2 \\div 3" + ) + @Iteration( + "numeric_1/(2+3)", "type=NUMERIC_EXPRESSION", "text=1/(2+3)", "expLatex=1 \\div (2 + 3)" + ) + @Iteration("numeric_1/2+3", "type=NUMERIC_EXPRESSION", "text=1/2+3", "expLatex=1 \\div 2 + 3") + @Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x/2", "expLatex=x \\div 2") + @Iteration( + "algebraic_x/y/z", "type=ALGEBRAIC_EXPRESSION", "text=x/y/z", "expLatex=x \\div y \\div z" + ) + @Iteration( + "algebraic_x/(2+y)", "type=ALGEBRAIC_EXPRESSION", "text=x/(2+y)", "expLatex=x \\div (2 + y)" ) + @Iteration( + "algebraic_x/2+y", "type=ALGEBRAIC_EXPRESSION", "text=x/2+y", "expLatex=x \\div 2 + y" + ) + @Iteration("math_eq_x/2", "type=MATH_EQUATION", "text=y=x/2", "expLatex=y = x \\div 2") + @Iteration( + "math_eq_x/y/z", + "type=MATH_EQUATION", + "text=y/2=x/y/z", + "expLatex=y \\div 2 = x \\div y \\div z" + ) + @Iteration( + "math_eq_x/(2+y)", "type=MATH_EQUATION", "text=x/(2+y)=y", "expLatex=x \\div (2 + y) = y" + ) + @Iteration("math_eq_x/2+y", "type=MATH_EQUATION", "text=x/2+y=y", "expLatex=x \\div 2 + y = y") fun testView_allInteractions_differentValidAnswers_divNotAsFractions_producesLatexWithDivs() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction(divAsFractions = false) @@ -562,46 +549,44 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1/2", "expLatex=\\frac{1}{2}"), - Iteration( - "numeric_1/2/3", "type=NUMERIC_EXPRESSION", "text=1/2/3", "expLatex=\\frac{\\frac{1}{2}}{3}" - ), - Iteration( - "numeric_1/(2+3)", "type=NUMERIC_EXPRESSION", "text=1/(2+3)", "expLatex=\\frac{1}{(2 + 3)}" - ), - Iteration( - "numeric_1/2+3", "type=NUMERIC_EXPRESSION", "text=1/2+3", "expLatex=\\frac{1}{2} + 3" - ), - Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x/2", "expLatex=\\frac{x}{2}"), - Iteration( - "algebraic_x/y/z", - "type=ALGEBRAIC_EXPRESSION", - "text=x/y/z", - "expLatex=\\frac{\\frac{x}{y}}{z}" - ), - Iteration( - "algebraic_x/(2+y)", - "type=ALGEBRAIC_EXPRESSION", - "text=x/(2+y)", - "expLatex=\\frac{x}{(2 + y)}" - ), - Iteration( - "algebraic_x/2+y", "type=ALGEBRAIC_EXPRESSION", "text=x/2+y", "expLatex=\\frac{x}{2} + y" - ), - Iteration("math_eq_x/2", "type=MATH_EQUATION", "text=y=x/2", "expLatex=y = \\frac{x}{2}"), - Iteration( - "math_eq_x/y/z", - "type=MATH_EQUATION", - "text=y/2=x/y/z", - "expLatex=\\frac{y}{2} = \\frac{\\frac{x}{y}}{z}" - ), - Iteration( - "math_eq_x/(2+y)", "type=MATH_EQUATION", "text=x/(2+y)=y", "expLatex=\\frac{x}{(2 + y)} = y" - ), - Iteration( - "math_eq_x/2+y", "type=MATH_EQUATION", "text=x/2+y=y", "expLatex=\\frac{x}{2} + y = y" - ) + @Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1/2", "expLatex=\\frac{1}{2}") + @Iteration( + "numeric_1/2/3", "type=NUMERIC_EXPRESSION", "text=1/2/3", "expLatex=\\frac{\\frac{1}{2}}{3}" + ) + @Iteration( + "numeric_1/(2+3)", "type=NUMERIC_EXPRESSION", "text=1/(2+3)", "expLatex=\\frac{1}{(2 + 3)}" + ) + @Iteration( + "numeric_1/2+3", "type=NUMERIC_EXPRESSION", "text=1/2+3", "expLatex=\\frac{1}{2} + 3" + ) + @Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x/2", "expLatex=\\frac{x}{2}") + @Iteration( + "algebraic_x/y/z", + "type=ALGEBRAIC_EXPRESSION", + "text=x/y/z", + "expLatex=\\frac{\\frac{x}{y}}{z}" + ) + @Iteration( + "algebraic_x/(2+y)", + "type=ALGEBRAIC_EXPRESSION", + "text=x/(2+y)", + "expLatex=\\frac{x}{(2 + y)}" + ) + @Iteration( + "algebraic_x/2+y", "type=ALGEBRAIC_EXPRESSION", "text=x/2+y", "expLatex=\\frac{x}{2} + y" + ) + @Iteration("math_eq_x/2", "type=MATH_EQUATION", "text=y=x/2", "expLatex=y = \\frac{x}{2}") + @Iteration( + "math_eq_x/y/z", + "type=MATH_EQUATION", + "text=y/2=x/y/z", + "expLatex=\\frac{y}{2} = \\frac{\\frac{x}{y}}{z}" + ) + @Iteration( + "math_eq_x/(2+y)", "type=MATH_EQUATION", "text=x/(2+y)=y", "expLatex=\\frac{x}{(2 + y)} = y" + ) + @Iteration( + "math_eq_x/2+y", "type=MATH_EQUATION", "text=x/2+y=y", "expLatex=\\frac{x}{2} + y = y" ) fun testView_allInteractions_differentValidAnswers_divAsFractions_producesLatexWithFractions() { val interactionType = MathInteractionType.valueOf(type) @@ -620,14 +605,12 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_invalid_exp_extra_error", "type=NUMERIC_EXPRESSION", "text=3/0"), - Iteration("numeric_invalid_exp_syntax_error", "type=NUMERIC_EXPRESSION", "text=3!"), - Iteration("algebraic_invalid_exp_extra_error", "type=ALGEBRAIC_EXPRESSION", "text=2^x"), - Iteration("algebraic_invalid_exp_syntax_error", "type=ALGEBRAIC_EXPRESSION", "text=2**x"), - Iteration("math_eq_invalid_exp_extra_error", "type=MATH_EQUATION", "text=y=+x"), - Iteration("math_eq_invalid_exp_syntax_error", "type=MATH_EQUATION", "text=y=x=z") - ) + @Iteration("numeric_invalid_exp_extra_error", "type=NUMERIC_EXPRESSION", "text=3/0") + @Iteration("numeric_invalid_exp_syntax_error", "type=NUMERIC_EXPRESSION", "text=3!") + @Iteration("algebraic_invalid_exp_extra_error", "type=ALGEBRAIC_EXPRESSION", "text=2^x") + @Iteration("algebraic_invalid_exp_syntax_error", "type=ALGEBRAIC_EXPRESSION", "text=2**x") + @Iteration("math_eq_invalid_exp_extra_error", "type=MATH_EQUATION", "text=y=+x") + @Iteration("math_eq_invalid_exp_syntax_error", "type=MATH_EQUATION", "text=y=x=z") fun testView_allInteractions_differentAnswers_failingAns_producesAnswerWithOrigExpAsPlainText() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() @@ -647,52 +630,50 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration( - "numeric_-1", "type=NUMERIC_EXPRESSION", "text= - 1 ", "expA11y=negative 1" - ), - Iteration("numeric_1+2", "type=NUMERIC_EXPRESSION", "text=1 + 2", "expA11y=1 plus 2"), - Iteration("numeric_1-2", "type=NUMERIC_EXPRESSION", "text=1 − 2", "expA11y=1 minus 2"), - Iteration("numeric_1*2", "type=NUMERIC_EXPRESSION", "text=1 × 2", "expA11y=1 times 2"), - Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1 ÷ 2", "expA11y=1 divided by 2"), - Iteration( - "numeric_long_exp", - "type=NUMERIC_EXPRESSION", - "text=3*2-3+4^3*8/3*2+7", - "expA11y=3 times 2 minus 3 plus 4 raised to the power of 3 times 8 divided by 3 times" + - " 2 plus 7" - ), - Iteration( - "algebraic_-x", "type=ALGEBRAIC_EXPRESSION", "text= - x ", "expA11y=negative x" - ), - Iteration("algebraic_x+2", "type=ALGEBRAIC_EXPRESSION", "text=x + 2", "expA11y=x plus 2"), - Iteration("algebraic_x-2", "type=ALGEBRAIC_EXPRESSION", "text=x − 2", "expA11y=x minus 2"), - Iteration("algebraic_x*2", "type=ALGEBRAIC_EXPRESSION", "text=x × 2", "expA11y=x times 2"), - Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x ÷ 2", "expA11y=x divided by 2"), - Iteration( - "algebraic_long_exp", - "type=ALGEBRAIC_EXPRESSION", - "text=12x^2y^2-(yz^2+yzx)-731z", - "expA11y=12 x raised to the power of 2 times y raised to the power of 2 minus open" + - " parenthesis y times zed raised to the power of 2 plus y times zed times x close" + - " parenthesis minus 731 zed" - ), - Iteration( - "math_eq_-x", "type=MATH_EQUATION", "text= y= - x ", "expA11y=y equals negative x" - ), - Iteration("math_eq_x+2", "type=MATH_EQUATION", "text=y = x + 2", "expA11y=y equals x plus 2"), - Iteration("math_eq_x-2", "type=MATH_EQUATION", "text=y = x − 2", "expA11y=y equals x minus 2"), - Iteration("math_eq_x*2", "type=MATH_EQUATION", "text=y = x × 2", "expA11y=y equals x times 2"), - Iteration( - "math_eq_x/2", "type=MATH_EQUATION", "text=y = x ÷ 2", "expA11y=y equals x divided by 2" - ), - Iteration( - "math_eq_long_exp", - "type=MATH_EQUATION", - "text=(x^2-1)/(x+1)=y/2", - "expA11y=open parenthesis x raised to the power of 2 minus 1 close parenthesis divided by" + - " open parenthesis x plus 1 close parenthesis equals y divided by 2" - ) + @Iteration( + "numeric_-1", "type=NUMERIC_EXPRESSION", "text= - 1 ", "expA11y=negative 1" + ) + @Iteration("numeric_1+2", "type=NUMERIC_EXPRESSION", "text=1 + 2", "expA11y=1 plus 2") + @Iteration("numeric_1-2", "type=NUMERIC_EXPRESSION", "text=1 − 2", "expA11y=1 minus 2") + @Iteration("numeric_1*2", "type=NUMERIC_EXPRESSION", "text=1 × 2", "expA11y=1 times 2") + @Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1 ÷ 2", "expA11y=1 divided by 2") + @Iteration( + "numeric_long_exp", + "type=NUMERIC_EXPRESSION", + "text=3*2-3+4^3*8/3*2+7", + "expA11y=3 times 2 minus 3 plus 4 raised to the power of 3 times 8 divided by 3 times" + + " 2 plus 7" + ) + @Iteration( + "algebraic_-x", "type=ALGEBRAIC_EXPRESSION", "text= - x ", "expA11y=negative x" + ) + @Iteration("algebraic_x+2", "type=ALGEBRAIC_EXPRESSION", "text=x + 2", "expA11y=x plus 2") + @Iteration("algebraic_x-2", "type=ALGEBRAIC_EXPRESSION", "text=x − 2", "expA11y=x minus 2") + @Iteration("algebraic_x*2", "type=ALGEBRAIC_EXPRESSION", "text=x × 2", "expA11y=x times 2") + @Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x ÷ 2", "expA11y=x divided by 2") + @Iteration( + "algebraic_long_exp", + "type=ALGEBRAIC_EXPRESSION", + "text=12x^2y^2-(yz^2+yzx)-731z", + "expA11y=12 x raised to the power of 2 times y raised to the power of 2 minus open" + + " parenthesis y times zed raised to the power of 2 plus y times zed times x close" + + " parenthesis minus 731 zed" + ) + @Iteration( + "math_eq_-x", "type=MATH_EQUATION", "text= y= - x ", "expA11y=y equals negative x" + ) + @Iteration("math_eq_x+2", "type=MATH_EQUATION", "text=y = x + 2", "expA11y=y equals x plus 2") + @Iteration("math_eq_x-2", "type=MATH_EQUATION", "text=y = x − 2", "expA11y=y equals x minus 2") + @Iteration("math_eq_x*2", "type=MATH_EQUATION", "text=y = x × 2", "expA11y=y equals x times 2") + @Iteration( + "math_eq_x/2", "type=MATH_EQUATION", "text=y = x ÷ 2", "expA11y=y equals x divided by 2" + ) + @Iteration( + "math_eq_long_exp", + "type=MATH_EQUATION", + "text=(x^2-1)/(x+1)=y/2", + "expA11y=open parenthesis x raised to the power of 2 minus 1 close parenthesis divided by" + + " open parenthesis x plus 1 close parenthesis equals y divided by 2" ) fun testView_allInteractions_diffAnswers_english_producesAnswerWithReadableContentDescription() { val interactionType = MathInteractionType.valueOf(type) @@ -712,61 +693,59 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1/2", "expA11y=1 divided by 2"), - Iteration( - "numeric_1/2/3", - "type=NUMERIC_EXPRESSION", - "text=1/2/3", - "expA11y=1 divided by 2 divided by 3" - ), - Iteration( - "numeric_1/(2+3)", - "type=NUMERIC_EXPRESSION", - "text=1/(2+3)", - "expA11y=1 divided by open parenthesis 2 plus 3 close parenthesis" - ), - Iteration( - "numeric_1/2+3", "type=NUMERIC_EXPRESSION", "text=1/2+3", "expA11y=1 divided by 2 plus 3" - ), - Iteration( - "numeric_1/3+3", "type=NUMERIC_EXPRESSION", "text=1/3+3", "expA11y=1 divided by 3 plus 3" - ), - Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x/2", "expA11y=x divided by 2"), - Iteration( - "algebraic_x/y/z", - "type=ALGEBRAIC_EXPRESSION", - "text=x/y/z", - "expA11y=x divided by y divided by zed" - ), - Iteration( - "algebraic_x/(2+y)", - "type=ALGEBRAIC_EXPRESSION", - "text=x/(2+y)", - "expA11y=x divided by open parenthesis 2 plus y close parenthesis" - ), - Iteration( - "algebraic_x/2+y", "type=ALGEBRAIC_EXPRESSION", "text=x/2+y", "expA11y=x divided by 2 plus y" - ), - Iteration("math_eq_x/2", "type=MATH_EQUATION", "text=y=x/2", "expA11y=y equals x divided by 2"), - Iteration( - "math_eq_x/y/z", - "type=MATH_EQUATION", - "text=y/2=x/y/z", - "expA11y=y divided by 2 equals x divided by y divided by zed" - ), - Iteration( - "math_eq_x/(2+y)", - "type=MATH_EQUATION", - "text=x/(2+y)=y", - "expA11y=x divided by open parenthesis 2 plus y close parenthesis equals y" - ), - Iteration( - "math_eq_x/2+y", - "type=MATH_EQUATION", - "text=x/2+y=y", - "expA11y=x divided by 2 plus y equals y" - ) + @Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1/2", "expA11y=1 divided by 2") + @Iteration( + "numeric_1/2/3", + "type=NUMERIC_EXPRESSION", + "text=1/2/3", + "expA11y=1 divided by 2 divided by 3" + ) + @Iteration( + "numeric_1/(2+3)", + "type=NUMERIC_EXPRESSION", + "text=1/(2+3)", + "expA11y=1 divided by open parenthesis 2 plus 3 close parenthesis" + ) + @Iteration( + "numeric_1/2+3", "type=NUMERIC_EXPRESSION", "text=1/2+3", "expA11y=1 divided by 2 plus 3" + ) + @Iteration( + "numeric_1/3+3", "type=NUMERIC_EXPRESSION", "text=1/3+3", "expA11y=1 divided by 3 plus 3" + ) + @Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x/2", "expA11y=x divided by 2") + @Iteration( + "algebraic_x/y/z", + "type=ALGEBRAIC_EXPRESSION", + "text=x/y/z", + "expA11y=x divided by y divided by zed" + ) + @Iteration( + "algebraic_x/(2+y)", + "type=ALGEBRAIC_EXPRESSION", + "text=x/(2+y)", + "expA11y=x divided by open parenthesis 2 plus y close parenthesis" + ) + @Iteration( + "algebraic_x/2+y", "type=ALGEBRAIC_EXPRESSION", "text=x/2+y", "expA11y=x divided by 2 plus y" + ) + @Iteration("math_eq_x/2", "type=MATH_EQUATION", "text=y=x/2", "expA11y=y equals x divided by 2") + @Iteration( + "math_eq_x/y/z", + "type=MATH_EQUATION", + "text=y/2=x/y/z", + "expA11y=y divided by 2 equals x divided by y divided by zed" + ) + @Iteration( + "math_eq_x/(2+y)", + "type=MATH_EQUATION", + "text=x/(2+y)=y", + "expA11y=x divided by open parenthesis 2 plus y close parenthesis equals y" + ) + @Iteration( + "math_eq_x/2+y", + "type=MATH_EQUATION", + "text=x/2+y=y", + "expA11y=x divided by 2 plus y equals y" ) fun testView_allInteractions_diffAnswers_english_divNotAsFractions_producesReadableContentDesc() { val interactionType = MathInteractionType.valueOf(type) @@ -786,61 +765,59 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1/2", "expA11y=one half"), - Iteration( - "numeric_1/2/3", - "type=NUMERIC_EXPRESSION", - "text=1/2/3", - "expA11y=the fraction with numerator one half and denominator 3" - ), - Iteration( - "numeric_1/(2+3)", - "type=NUMERIC_EXPRESSION", - "text=1/(2+3)", - "expA11y=the fraction with numerator 1 and denominator open parenthesis 2 plus 3 close" + - " parenthesis" - ), - Iteration( - "numeric_1/2+3", "type=NUMERIC_EXPRESSION", "text=1/2+3", "expA11y=one half plus 3" - ), - Iteration( - "numeric_1/3+3", "type=NUMERIC_EXPRESSION", "text=1/3+3", "expA11y=1 over 3 plus 3" - ), - Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x/2", "expA11y=x over 2"), - Iteration( - "algebraic_x/y/z", - "type=ALGEBRAIC_EXPRESSION", - "text=x/y/z", - "expA11y=the fraction with numerator x over y and denominator zed" - ), - Iteration( - "algebraic_x/(2+y)", - "type=ALGEBRAIC_EXPRESSION", - "text=x/(2+y)", - "expA11y=the fraction with numerator x and denominator open parenthesis 2 plus y close" + - " parenthesis" - ), - Iteration( - "algebraic_x/2+y", "type=ALGEBRAIC_EXPRESSION", "text=x/2+y", "expA11y=x over 2 plus y" - ), - Iteration("math_eq_x/2", "type=MATH_EQUATION", "text=y=x/2", "expA11y=y equals x over 2"), - Iteration( - "math_eq_x/y/z", - "type=MATH_EQUATION", - "text=y/2=x/y/z", - "expA11y=y over 2 equals the fraction with numerator x over y and denominator zed" - ), - Iteration( - "math_eq_x/(2+y)", - "type=MATH_EQUATION", - "text=x/(2+y)=y", - "expA11y=the fraction with numerator x and denominator open parenthesis 2 plus y close" + - " parenthesis equals y" - ), - Iteration( - "math_eq_x/2+y", "type=MATH_EQUATION", "text=x/2+y=y", "expA11y=x over 2 plus y equals y" - ) + @Iteration("numeric_1/2", "type=NUMERIC_EXPRESSION", "text=1/2", "expA11y=one half") + @Iteration( + "numeric_1/2/3", + "type=NUMERIC_EXPRESSION", + "text=1/2/3", + "expA11y=the fraction with numerator one half and denominator 3" + ) + @Iteration( + "numeric_1/(2+3)", + "type=NUMERIC_EXPRESSION", + "text=1/(2+3)", + "expA11y=the fraction with numerator 1 and denominator open parenthesis 2 plus 3 close" + + " parenthesis" + ) + @Iteration( + "numeric_1/2+3", "type=NUMERIC_EXPRESSION", "text=1/2+3", "expA11y=one half plus 3" + ) + @Iteration( + "numeric_1/3+3", "type=NUMERIC_EXPRESSION", "text=1/3+3", "expA11y=1 over 3 plus 3" + ) + @Iteration("algebraic_x/2", "type=ALGEBRAIC_EXPRESSION", "text=x/2", "expA11y=x over 2") + @Iteration( + "algebraic_x/y/z", + "type=ALGEBRAIC_EXPRESSION", + "text=x/y/z", + "expA11y=the fraction with numerator x over y and denominator zed" + ) + @Iteration( + "algebraic_x/(2+y)", + "type=ALGEBRAIC_EXPRESSION", + "text=x/(2+y)", + "expA11y=the fraction with numerator x and denominator open parenthesis 2 plus y close" + + " parenthesis" + ) + @Iteration( + "algebraic_x/2+y", "type=ALGEBRAIC_EXPRESSION", "text=x/2+y", "expA11y=x over 2 plus y" + ) + @Iteration("math_eq_x/2", "type=MATH_EQUATION", "text=y=x/2", "expA11y=y equals x over 2") + @Iteration( + "math_eq_x/y/z", + "type=MATH_EQUATION", + "text=y/2=x/y/z", + "expA11y=y over 2 equals the fraction with numerator x over y and denominator zed" + ) + @Iteration( + "math_eq_x/(2+y)", + "type=MATH_EQUATION", + "text=x/(2+y)=y", + "expA11y=the fraction with numerator x and denominator open parenthesis 2 plus y close" + + " parenthesis equals y" + ) + @Iteration( + "math_eq_x/2+y", "type=MATH_EQUATION", "text=x/2+y=y", "expA11y=x over 2 plus y equals y" ) fun testView_allInteractions_diffAnswers_english_divAsFractions_producesReadableContentDesc() { val interactionType = MathInteractionType.valueOf(type) @@ -860,14 +837,12 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_invalid_exp_extra_error", "type=NUMERIC_EXPRESSION", "text=3/0"), - Iteration("numeric_invalid_exp_syntax_error", "type=NUMERIC_EXPRESSION", "text=3!"), - Iteration("algebraic_invalid_exp_extra_error", "type=ALGEBRAIC_EXPRESSION", "text=2^x"), - Iteration("algebraic_invalid_exp_syntax_error", "type=ALGEBRAIC_EXPRESSION", "text=2**x"), - Iteration("math_eq_invalid_exp_extra_error", "type=MATH_EQUATION", "text=y=+x"), - Iteration("math_eq_invalid_exp_syntax_error", "type=MATH_EQUATION", "text=y=x=z") - ) + @Iteration("numeric_invalid_exp_extra_error", "type=NUMERIC_EXPRESSION", "text=3/0") + @Iteration("numeric_invalid_exp_syntax_error", "type=NUMERIC_EXPRESSION", "text=3!") + @Iteration("algebraic_invalid_exp_extra_error", "type=ALGEBRAIC_EXPRESSION", "text=2^x") + @Iteration("algebraic_invalid_exp_syntax_error", "type=ALGEBRAIC_EXPRESSION", "text=2**x") + @Iteration("math_eq_invalid_exp_extra_error", "type=MATH_EQUATION", "text=y=+x") + @Iteration("math_eq_invalid_exp_syntax_error", "type=MATH_EQUATION", "text=y=x=z") fun testView_allInteractions_invalidAnswers_english_producesAnswerOriginalExpAsDescription() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() @@ -887,26 +862,24 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numexp_unsp", "type=NUMERIC_EXPRESSION", "lang=LANGUAGE_UNSPECIFIED", "text=3*2"), - Iteration("numexp_ar", "type=NUMERIC_EXPRESSION", "lang=ARABIC", "text=3*2"), - Iteration("numexp_hi", "type=NUMERIC_EXPRESSION", "lang=HINDI", "text=3*2"), - Iteration("numexp_hi-EN", "type=NUMERIC_EXPRESSION", "lang=HINGLISH", "text=3*2"), - Iteration("numexp_pt", "type=NUMERIC_EXPRESSION", "lang=PORTUGUESE", "text=3*2"), - Iteration("numexp_pt-BR", "type=NUMERIC_EXPRESSION", "lang=BRAZILIAN_PORTUGUESE", "text=3*2"), - Iteration("algexp_unsp", "type=ALGEBRAIC_EXPRESSION", "lang=LANGUAGE_UNSPECIFIED", "text=x*2"), - Iteration("algexp_ar", "type=ALGEBRAIC_EXPRESSION", "lang=ARABIC", "text=x*2"), - Iteration("algexp_hi", "type=ALGEBRAIC_EXPRESSION", "lang=HINDI", "text=x*2"), - Iteration("algexp_hi-EN", "type=ALGEBRAIC_EXPRESSION", "lang=HINGLISH", "text=x*2"), - Iteration("algexp_pt", "type=ALGEBRAIC_EXPRESSION", "lang=PORTUGUESE", "text=x*2"), - Iteration("algexp_pt-BR", "type=ALGEBRAIC_EXPRESSION", "lang=BRAZILIAN_PORTUGUESE", "text=x*2"), - Iteration("matheq_unsp", "type=MATH_EQUATION", "lang=LANGUAGE_UNSPECIFIED", "text=y=x"), - Iteration("matheq_ar", "type=MATH_EQUATION", "lang=ARABIC", "text=y=x"), - Iteration("matheq_hi", "type=MATH_EQUATION", "lang=HINDI", "text=y=x"), - Iteration("matheq_hi-EN", "type=MATH_EQUATION", "lang=HINGLISH", "text=y=x"), - Iteration("matheq_pt", "type=MATH_EQUATION", "lang=PORTUGUESE", "text=y=x"), - Iteration("matheq_pt-BR", "type=MATH_EQUATION", "lang=BRAZILIAN_PORTUGUESE", "text=y=x") - ) + @Iteration("numexp_unsp", "type=NUMERIC_EXPRESSION", "lang=LANGUAGE_UNSPECIFIED", "text=3*2") + @Iteration("numexp_ar", "type=NUMERIC_EXPRESSION", "lang=ARABIC", "text=3*2") + @Iteration("numexp_hi", "type=NUMERIC_EXPRESSION", "lang=HINDI", "text=3*2") + @Iteration("numexp_hi-EN", "type=NUMERIC_EXPRESSION", "lang=HINGLISH", "text=3*2") + @Iteration("numexp_pt", "type=NUMERIC_EXPRESSION", "lang=PORTUGUESE", "text=3*2") + @Iteration("numexp_pt-BR", "type=NUMERIC_EXPRESSION", "lang=BRAZILIAN_PORTUGUESE", "text=3*2") + @Iteration("algexp_unsp", "type=ALGEBRAIC_EXPRESSION", "lang=LANGUAGE_UNSPECIFIED", "text=x*2") + @Iteration("algexp_ar", "type=ALGEBRAIC_EXPRESSION", "lang=ARABIC", "text=x*2") + @Iteration("algexp_hi", "type=ALGEBRAIC_EXPRESSION", "lang=HINDI", "text=x*2") + @Iteration("algexp_hi-EN", "type=ALGEBRAIC_EXPRESSION", "lang=HINGLISH", "text=x*2") + @Iteration("algexp_pt", "type=ALGEBRAIC_EXPRESSION", "lang=PORTUGUESE", "text=x*2") + @Iteration("algexp_pt-BR", "type=ALGEBRAIC_EXPRESSION", "lang=BRAZILIAN_PORTUGUESE", "text=x*2") + @Iteration("matheq_unsp", "type=MATH_EQUATION", "lang=LANGUAGE_UNSPECIFIED", "text=y=x") + @Iteration("matheq_ar", "type=MATH_EQUATION", "lang=ARABIC", "text=y=x") + @Iteration("matheq_hi", "type=MATH_EQUATION", "lang=HINDI", "text=y=x") + @Iteration("matheq_hi-EN", "type=MATH_EQUATION", "lang=HINGLISH", "text=y=x") + @Iteration("matheq_pt", "type=MATH_EQUATION", "lang=PORTUGUESE", "text=y=x") + @Iteration("matheq_pt-BR", "type=MATH_EQUATION", "lang=BRAZILIAN_PORTUGUESE", "text=y=x") fun testView_allInteractions_unsupportedLang_producesAnswerOriginalExpAsDescription() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() @@ -930,175 +903,173 @@ class MathExpressionInteractionsViewTest { // they're the same for all possible expressions/equations that can produce that error), and // aren't tied to specific interaction types. @Test - @RunParameterized( - Iteration( - "numexp_exp_too_large", - "type=NUMERIC_EXPRESSION", - "text=2^10", - "expErr=Sorry, powers higher than 5 are not supported by the app. Please revise your answer." - ), - Iteration( - "numexp_exp_incomplete_func_name", - "type=NUMERIC_EXPRESSION", - "text=sqr(2)", - "expErr=Did you mean sqrt? If not, please separate the variables with multiplication symbols." - ), - Iteration( - "numexp_exp_hanging_square_root", - "type=NUMERIC_EXPRESSION", - "text=√", - "expErr=Missing input for square root." - ), - Iteration( - "numexp_exp_nested_exponent", - "type=NUMERIC_EXPRESSION", - "text=2^3^4", - "expErr=Sorry, repeated powers/exponents are not supported by the app. Please limit your" + - " answer to one power." - ), - Iteration( - "numexp_exp_spaces_in_number_input", - "type=NUMERIC_EXPRESSION", - "text=3.14 1", - "expErr=Please remove the spaces between numbers in your answer." - ), - Iteration( - "numexp_exp_consecutive_unary", - "type=NUMERIC_EXPRESSION", - "text=--2", - "expErr=Please remove the extra symbols in your answer." - ), - Iteration( - "numexp_exp_divide_by_zero", - "type=NUMERIC_EXPRESSION", - "text=2/0", - "expErr=Dividing by zero is invalid. Please revise your answer." - ), - Iteration( - "numexp_exp_hanging_parenthesis", - "type=NUMERIC_EXPRESSION", - "text=2+(3-1", - "expErr=Please close or remove parentheses." - ), - Iteration( - "numexp_exp_generic_error", - "type=NUMERIC_EXPRESSION", - "text=sqrt 2", - "expErr=Sorry, we couldn't understand your answer. Please check it to make sure there" + - " aren't any errors." - ), - Iteration( - "algexp_exp_too_large", - "type=ALGEBRAIC_EXPRESSION", - "text=x^10", - "expErr=Sorry, powers higher than 5 are not supported by the app. Please revise your answer." - ), - Iteration( - "algexp_exp_incomplete_func_name", - "type=ALGEBRAIC_EXPRESSION", - "text=sqr(x)", - "expErr=Did you mean sqrt? If not, please separate the variables with multiplication symbols." - ), - Iteration( - "algexp_exp_hanging_square_root", - "type=ALGEBRAIC_EXPRESSION", - "text=√", - "expErr=Missing input for square root." - ), - Iteration( - "algexp_exp_nested_exponent", - "type=ALGEBRAIC_EXPRESSION", - "text=x^3^4", - "expErr=Sorry, repeated powers/exponents are not supported by the app. Please limit your" + - " answer to one power." - ), - Iteration( - "algexp_exp_spaces_in_number_input", - "type=ALGEBRAIC_EXPRESSION", - "text=3.14 1", - "expErr=Please remove the spaces between numbers in your answer." - ), - Iteration( - "algexp_exp_consecutive_unary", - "type=ALGEBRAIC_EXPRESSION", - "text=--x", - "expErr=Please remove the extra symbols in your answer." - ), - Iteration( - "algexp_exp_divide_by_zero", - "type=ALGEBRAIC_EXPRESSION", - "text=x/0", - "expErr=Dividing by zero is invalid. Please revise your answer." - ), - Iteration( - "algexp_exp_hanging_parenthesis", - "type=ALGEBRAIC_EXPRESSION", - "text=x+(y-z", - "expErr=Please close or remove parentheses." - ), - Iteration( - "algexp_exp_generic_error", - "type=ALGEBRAIC_EXPRESSION", - "text=sqrt x", - "expErr=Sorry, we couldn't understand your answer. Please check it to make sure there" + - " aren't any errors." - ), - Iteration( - "matheq_exp_too_large", - "type=MATH_EQUATION", - "text=y=x^10", - "expErr=Sorry, powers higher than 5 are not supported by the app. Please revise your answer." - ), - Iteration( - "matheq_exp_incomplete_func_name", - "type=MATH_EQUATION", - "text=y=sqr(x)", - "expErr=Did you mean sqrt? If not, please separate the variables with multiplication symbols." - ), - Iteration( - "matheq_exp_hanging_square_root", - "type=MATH_EQUATION", - "text=y=√", - "expErr=Missing input for square root." - ), - Iteration( - "matheq_exp_nested_exponent", - "type=MATH_EQUATION", - "text=y=x^3^4", - "expErr=Sorry, repeated powers/exponents are not supported by the app. Please limit your" + - " answer to one power." - ), - Iteration( - "matheq_exp_spaces_in_number_input", - "type=MATH_EQUATION", - "text=y=3.14 1", - "expErr=Please remove the spaces between numbers in your answer." - ), - Iteration( - "matheq_exp_consecutive_unary", - "type=MATH_EQUATION", - "text=y=--x", - "expErr=Please remove the extra symbols in your answer." - ), - Iteration( - "matheq_exp_divide_by_zero", - "type=MATH_EQUATION", - "text=y=x/0", - "expErr=Dividing by zero is invalid. Please revise your answer." - ), - Iteration( - "matheq_exp_hanging_parenthesis", - "type=MATH_EQUATION", - "text=y=x+(y-z", - "expErr=Please close or remove parentheses." - ), - Iteration( - "matheq_exp_generic_error", - "type=MATH_EQUATION", - "text=y=sqrt x", - "expErr=Sorry, we couldn't understand your answer. Please check it to make sure there" + - " aren't any errors." - ) + @Iteration( + "numexp_exp_too_large", + "type=NUMERIC_EXPRESSION", + "text=2^10", + "expErr=Sorry, powers higher than 5 are not supported by the app. Please revise your answer." + ) + @Iteration( + "numexp_exp_incomplete_func_name", + "type=NUMERIC_EXPRESSION", + "text=sqr(2)", + "expErr=Did you mean sqrt? If not, please separate the variables with multiplication symbols." + ) + @Iteration( + "numexp_exp_hanging_square_root", + "type=NUMERIC_EXPRESSION", + "text=√", + "expErr=Missing input for square root." + ) + @Iteration( + "numexp_exp_nested_exponent", + "type=NUMERIC_EXPRESSION", + "text=2^3^4", + "expErr=Sorry, repeated powers/exponents are not supported by the app. Please limit your" + + " answer to one power." + ) + @Iteration( + "numexp_exp_spaces_in_number_input", + "type=NUMERIC_EXPRESSION", + "text=3.14 1", + "expErr=Please remove the spaces between numbers in your answer." + ) + @Iteration( + "numexp_exp_consecutive_unary", + "type=NUMERIC_EXPRESSION", + "text=--2", + "expErr=Please remove the extra symbols in your answer." + ) + @Iteration( + "numexp_exp_divide_by_zero", + "type=NUMERIC_EXPRESSION", + "text=2/0", + "expErr=Dividing by zero is invalid. Please revise your answer." + ) + @Iteration( + "numexp_exp_hanging_parenthesis", + "type=NUMERIC_EXPRESSION", + "text=2+(3-1", + "expErr=Please close or remove parentheses." + ) + @Iteration( + "numexp_exp_generic_error", + "type=NUMERIC_EXPRESSION", + "text=sqrt 2", + "expErr=Sorry, we couldn't understand your answer. Please check it to make sure there" + + " aren't any errors." + ) + @Iteration( + "algexp_exp_too_large", + "type=ALGEBRAIC_EXPRESSION", + "text=x^10", + "expErr=Sorry, powers higher than 5 are not supported by the app. Please revise your answer." + ) + @Iteration( + "algexp_exp_incomplete_func_name", + "type=ALGEBRAIC_EXPRESSION", + "text=sqr(x)", + "expErr=Did you mean sqrt? If not, please separate the variables with multiplication symbols." + ) + @Iteration( + "algexp_exp_hanging_square_root", + "type=ALGEBRAIC_EXPRESSION", + "text=√", + "expErr=Missing input for square root." + ) + @Iteration( + "algexp_exp_nested_exponent", + "type=ALGEBRAIC_EXPRESSION", + "text=x^3^4", + "expErr=Sorry, repeated powers/exponents are not supported by the app. Please limit your" + + " answer to one power." + ) + @Iteration( + "algexp_exp_spaces_in_number_input", + "type=ALGEBRAIC_EXPRESSION", + "text=3.14 1", + "expErr=Please remove the spaces between numbers in your answer." + ) + @Iteration( + "algexp_exp_consecutive_unary", + "type=ALGEBRAIC_EXPRESSION", + "text=--x", + "expErr=Please remove the extra symbols in your answer." + ) + @Iteration( + "algexp_exp_divide_by_zero", + "type=ALGEBRAIC_EXPRESSION", + "text=x/0", + "expErr=Dividing by zero is invalid. Please revise your answer." + ) + @Iteration( + "algexp_exp_hanging_parenthesis", + "type=ALGEBRAIC_EXPRESSION", + "text=x+(y-z", + "expErr=Please close or remove parentheses." + ) + @Iteration( + "algexp_exp_generic_error", + "type=ALGEBRAIC_EXPRESSION", + "text=sqrt x", + "expErr=Sorry, we couldn't understand your answer. Please check it to make sure there" + + " aren't any errors." + ) + @Iteration( + "matheq_exp_too_large", + "type=MATH_EQUATION", + "text=y=x^10", + "expErr=Sorry, powers higher than 5 are not supported by the app. Please revise your answer." + ) + @Iteration( + "matheq_exp_incomplete_func_name", + "type=MATH_EQUATION", + "text=y=sqr(x)", + "expErr=Did you mean sqrt? If not, please separate the variables with multiplication symbols." + ) + @Iteration( + "matheq_exp_hanging_square_root", + "type=MATH_EQUATION", + "text=y=√", + "expErr=Missing input for square root." + ) + @Iteration( + "matheq_exp_nested_exponent", + "type=MATH_EQUATION", + "text=y=x^3^4", + "expErr=Sorry, repeated powers/exponents are not supported by the app. Please limit your" + + " answer to one power." + ) + @Iteration( + "matheq_exp_spaces_in_number_input", + "type=MATH_EQUATION", + "text=y=3.14 1", + "expErr=Please remove the spaces between numbers in your answer." + ) + @Iteration( + "matheq_exp_consecutive_unary", + "type=MATH_EQUATION", + "text=y=--x", + "expErr=Please remove the extra symbols in your answer." + ) + @Iteration( + "matheq_exp_divide_by_zero", + "type=MATH_EQUATION", + "text=y=x/0", + "expErr=Dividing by zero is invalid. Please revise your answer." + ) + @Iteration( + "matheq_exp_hanging_parenthesis", + "type=MATH_EQUATION", + "text=y=x+(y-z", + "expErr=Please close or remove parentheses." + ) + @Iteration( + "matheq_exp_generic_error", + "type=MATH_EQUATION", + "text=y=sqrt x", + "expErr=Sorry, we couldn't understand your answer. Please check it to make sure there" + + " aren't any errors." ) fun testView_allInteractions_invalidAnswer_casesWithNoCustomization_producesError() { val interactionType = MathInteractionType.valueOf(type) @@ -1135,10 +1106,8 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("alg_exp", "type=ALGEBRAIC_EXPRESSION", "text=2^x"), - Iteration("math_equation", "type=MATH_EQUATION", "text=y=2^x") - ) + @Iteration("alg_exp", "type=ALGEBRAIC_EXPRESSION", "text=2^x") + @Iteration("math_equation", "type=MATH_EQUATION", "text=y=2^x") fun testView_algebraicInteractions_variableInExponent_producesError() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() @@ -1158,22 +1127,20 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("y", "text=y", "expErr=Your equation is missing an '=' sign."), - Iteration("2y", "text=2y", "expErr=Your equation is missing an '=' sign."), - Iteration( - "y==x", - "text=y==x", - "expErr=Your equation contains too many '=' signs. It should have only one." - ), - Iteration("y=", "text=y=", "expErr=One of the sides of '=' in your equation is empty."), - Iteration("=x", "text==x", "expErr=One of the sides of '=' in your equation is empty."), - Iteration("=y=x", "text==y=x", "expErr=One of the sides of '=' in your equation is empty."), - Iteration( - "y=x=", - "text=y=x=", - "expErr=Your equation contains too many '=' signs. It should have only one." - ) + @Iteration("y", "text=y", "expErr=Your equation is missing an '=' sign.") + @Iteration("2y", "text=2y", "expErr=Your equation is missing an '=' sign.") + @Iteration( + "y==x", + "text=y==x", + "expErr=Your equation contains too many '=' signs. It should have only one." + ) + @Iteration("y=", "text=y=", "expErr=One of the sides of '=' in your equation is empty.") + @Iteration("=x", "text==x", "expErr=One of the sides of '=' in your equation is empty.") + @Iteration("=y=x", "text==y=x", "expErr=One of the sides of '=' in your equation is empty.") + @Iteration( + "y=x=", + "text=y=x=", + "expErr=Your equation contains too many '=' signs. It should have only one." ) fun testView_mathEquationInput_incorrectEqualsUsage_producesError() { launchForMathEquations(interaction = createInteraction()).use { scenario -> @@ -1189,11 +1156,9 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("num_exp", "type=NUMERIC_EXPRESSION", "text=abs(2)"), - Iteration("alg_exp", "type=ALGEBRAIC_EXPRESSION", "text=abs(x)"), - Iteration("math_equation", "type=MATH_EQUATION", "text=y=abs(x)") - ) + @Iteration("num_exp", "type=NUMERIC_EXPRESSION", "text=abs(2)") + @Iteration("alg_exp", "type=ALGEBRAIC_EXPRESSION", "text=abs(x)") + @Iteration("math_equation", "type=MATH_EQUATION", "text=y=abs(x)") fun testView_allInteractions_invalidFunctionAnswer_producesError() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() @@ -1212,25 +1177,23 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration( - "num_exp", - "type=NUMERIC_EXPRESSION", - "text=1+((2* 3))", - "expErr=Please remove extra parentheses around the '((2* 3))', for example: '(2* 3)'." - ), - Iteration( - "alg_exp", - "type=ALGEBRAIC_EXPRESSION", - "text=x+((y* z))", - "expErr=Please remove extra parentheses around the '((y* z))', for example: '(y* z)'." - ), - Iteration( - "math_equation", - "type=MATH_EQUATION", - "text=y=x+((y* z))", - "expErr=Please remove extra parentheses around the '((y* z))', for example: '(y* z)'." - ) + @Iteration( + "num_exp", + "type=NUMERIC_EXPRESSION", + "text=1+((2* 3))", + "expErr=Please remove extra parentheses around the '((2* 3))', for example: '(2* 3)'." + ) + @Iteration( + "alg_exp", + "type=ALGEBRAIC_EXPRESSION", + "text=x+((y* z))", + "expErr=Please remove extra parentheses around the '((y* z))', for example: '(y* z)'." + ) + @Iteration( + "math_equation", + "type=MATH_EQUATION", + "text=y=x+((y* z))", + "expErr=Please remove extra parentheses around the '((y* z))', for example: '(y* z)'." ) fun testView_allInteractions_multipleRedundantParentheses_producesError() { val interactionType = MathInteractionType.valueOf(type) @@ -1249,25 +1212,23 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration( - "num_exp", - "type=NUMERIC_EXPRESSION", - "text=1+(2 )", - "expErr=Please remove the extra parentheses around '(2)', for example: '2'." - ), - Iteration( - "alg_exp", - "type=ALGEBRAIC_EXPRESSION", - "text=x+(y )", - "expErr=Please remove the extra parentheses around '(y)', for example: 'y'." - ), - Iteration( - "math_equation", - "type=MATH_EQUATION", - "text=y=x+(y )", - "expErr=Please remove the extra parentheses around '(y)', for example: 'y'." - ) + @Iteration( + "num_exp", + "type=NUMERIC_EXPRESSION", + "text=1+(2 )", + "expErr=Please remove the extra parentheses around '(2)', for example: '2'." + ) + @Iteration( + "alg_exp", + "type=ALGEBRAIC_EXPRESSION", + "text=x+(y )", + "expErr=Please remove the extra parentheses around '(y)', for example: 'y'." + ) + @Iteration( + "math_equation", + "type=MATH_EQUATION", + "text=y=x+(y )", + "expErr=Please remove the extra parentheses around '(y)', for example: 'y'." ) fun testView_allInteractions_individualRedundantParentheses_producesError() { val interactionType = MathInteractionType.valueOf(type) @@ -1286,25 +1247,23 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration( - "num_exp", - "type=NUMERIC_EXPRESSION", - "text=(1+2 )", - "expErr=Please remove the parentheses around the whole answer: '(1+2 )'." - ), - Iteration( - "alg_exp", - "type=ALGEBRAIC_EXPRESSION", - "text=(x+y )", - "expErr=Please remove the parentheses around the whole answer: '(x+y )'." - ), - Iteration( - "math_equation", - "type=MATH_EQUATION", - "text=y=(x+y )", - "expErr=Please remove the parentheses around the whole answer: '(x+y )'." - ) + @Iteration( + "num_exp", + "type=NUMERIC_EXPRESSION", + "text=(1+2 )", + "expErr=Please remove the parentheses around the whole answer: '(1+2 )'." + ) + @Iteration( + "alg_exp", + "type=ALGEBRAIC_EXPRESSION", + "text=(x+y )", + "expErr=Please remove the parentheses around the whole answer: '(x+y )'." + ) + @Iteration( + "math_equation", + "type=MATH_EQUATION", + "text=y=(x+y )", + "expErr=Please remove the parentheses around the whole answer: '(x+y )'." ) fun testView_allInteractions_singleRedundantParentheses_producesError() { val interactionType = MathInteractionType.valueOf(type) @@ -1323,97 +1282,95 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration( - "numeric_expression_add", - "type=NUMERIC_EXPRESSION", - "text=1+", - "expErr=There seems to be a number or a variable missing after the addition symbol '+'." - ), - Iteration( - "numeric_expression_subtract", - "type=NUMERIC_EXPRESSION", - "text=1−", - "expErr=There seems to be a number or a variable missing after the subtraction symbol '−'." - ), - Iteration( - "numeric_expression_multiply", - "type=NUMERIC_EXPRESSION", - "text=1×", - "expErr=There seems to be a number or a variable missing after the multiplication symbol '×'." - ), - Iteration( - "numeric_expression_divide", - "type=NUMERIC_EXPRESSION", - "text=1÷", - "expErr=There seems to be a number or a variable missing after the division symbol '÷'." - ), - Iteration( - "numeric_expression_exponentiate", - "type=NUMERIC_EXPRESSION", - "text=1^", - "expErr=There seems to be a number or a variable missing after the exponentiation symbol '^'." - ), - Iteration( - "algebraic_expression_add", - "type=ALGEBRAIC_EXPRESSION", - "text=x+", - "expErr=There seems to be a number or a variable missing after the addition symbol '+'." - ), - Iteration( - "algebraic_expression_subtract", - "type=ALGEBRAIC_EXPRESSION", - "text=x−", - "expErr=There seems to be a number or a variable missing after the subtraction symbol '−'." - ), - Iteration( - "algebraic_expression_multiply", - "type=ALGEBRAIC_EXPRESSION", - "text=x×", - "expErr=There seems to be a number or a variable missing after the multiplication symbol '×'." - ), - Iteration( - "algebraic_expression_divide", - "type=ALGEBRAIC_EXPRESSION", - "text=x÷", - "expErr=There seems to be a number or a variable missing after the division symbol '÷'." - ), - Iteration( - "algebraic_expression_exponentiate", - "type=ALGEBRAIC_EXPRESSION", - "text=x^", - "expErr=There seems to be a number or a variable missing after the exponentiation symbol '^'." - ), - Iteration( - "math_equation_add", - "type=MATH_EQUATION", - "text=y=x+", - "expErr=There seems to be a number or a variable missing after the addition symbol '+'." - ), - Iteration( - "math_equation_subtract", - "type=MATH_EQUATION", - "text=y=x−", - "expErr=There seems to be a number or a variable missing after the subtraction symbol '−'." - ), - Iteration( - "math_equation_multiply", - "type=MATH_EQUATION", - "text=y=x×", - "expErr=There seems to be a number or a variable missing after the multiplication symbol '×'." - ), - Iteration( - "math_equation_divide", - "type=MATH_EQUATION", - "text=y=x÷", - "expErr=There seems to be a number or a variable missing after the division symbol '÷'." - ), - Iteration( - "math_equation_exponentiate", - "type=MATH_EQUATION", - "text=y=x^", - "expErr=There seems to be a number or a variable missing after the exponentiation symbol '^'." - ) + @Iteration( + "numeric_expression_add", + "type=NUMERIC_EXPRESSION", + "text=1+", + "expErr=There seems to be a number or a variable missing after the addition symbol '+'." + ) + @Iteration( + "numeric_expression_subtract", + "type=NUMERIC_EXPRESSION", + "text=1−", + "expErr=There seems to be a number or a variable missing after the subtraction symbol '−'." + ) + @Iteration( + "numeric_expression_multiply", + "type=NUMERIC_EXPRESSION", + "text=1×", + "expErr=There seems to be a number or a variable missing after the multiplication symbol '×'." + ) + @Iteration( + "numeric_expression_divide", + "type=NUMERIC_EXPRESSION", + "text=1÷", + "expErr=There seems to be a number or a variable missing after the division symbol '÷'." + ) + @Iteration( + "numeric_expression_exponentiate", + "type=NUMERIC_EXPRESSION", + "text=1^", + "expErr=There seems to be a number or a variable missing after the exponentiation symbol '^'." + ) + @Iteration( + "algebraic_expression_add", + "type=ALGEBRAIC_EXPRESSION", + "text=x+", + "expErr=There seems to be a number or a variable missing after the addition symbol '+'." + ) + @Iteration( + "algebraic_expression_subtract", + "type=ALGEBRAIC_EXPRESSION", + "text=x−", + "expErr=There seems to be a number or a variable missing after the subtraction symbol '−'." + ) + @Iteration( + "algebraic_expression_multiply", + "type=ALGEBRAIC_EXPRESSION", + "text=x×", + "expErr=There seems to be a number or a variable missing after the multiplication symbol '×'." + ) + @Iteration( + "algebraic_expression_divide", + "type=ALGEBRAIC_EXPRESSION", + "text=x÷", + "expErr=There seems to be a number or a variable missing after the division symbol '÷'." + ) + @Iteration( + "algebraic_expression_exponentiate", + "type=ALGEBRAIC_EXPRESSION", + "text=x^", + "expErr=There seems to be a number or a variable missing after the exponentiation symbol '^'." + ) + @Iteration( + "math_equation_add", + "type=MATH_EQUATION", + "text=y=x+", + "expErr=There seems to be a number or a variable missing after the addition symbol '+'." + ) + @Iteration( + "math_equation_subtract", + "type=MATH_EQUATION", + "text=y=x−", + "expErr=There seems to be a number or a variable missing after the subtraction symbol '−'." + ) + @Iteration( + "math_equation_multiply", + "type=MATH_EQUATION", + "text=y=x×", + "expErr=There seems to be a number or a variable missing after the multiplication symbol '×'." + ) + @Iteration( + "math_equation_divide", + "type=MATH_EQUATION", + "text=y=x÷", + "expErr=There seems to be a number or a variable missing after the division symbol '÷'." + ) + @Iteration( + "math_equation_exponentiate", + "type=MATH_EQUATION", + "text=y=x^", + "expErr=There seems to be a number or a variable missing after the exponentiation symbol '^'." ) fun testView_allInteractions_noVarOrNumberAfterBinaryOpted_producesError() { val interactionType = MathInteractionType.valueOf(type) @@ -1434,91 +1391,89 @@ class MathExpressionInteractionsViewTest { // Note that subtraction is omitted here since expressions like '-2' would be treated as negative // 2 rather than a subtraction being assumed. @Test - @RunParameterized( - Iteration( - "numeric_expression_add", - "type=NUMERIC_EXPRESSION", - "text=+1", - "expErr=Is there a number or a variable missing before or after the addition symbol '+'? If" + - " not, please remove the extra '+'." - ), - Iteration( - "numeric_expression_multiply", - "type=NUMERIC_EXPRESSION", - "text=×1", - "expErr=Is there a number or a variable missing before or after the multiplication symbol" + - " '×'? If not, please remove the extra '×'." - ), - Iteration( - "numeric_expression_divide", - "type=NUMERIC_EXPRESSION", - "text=÷1", - "expErr=Is there a number or a variable missing before or after the division symbol '÷'? If" + - " not, please remove the extra '÷'." - ), - Iteration( - "numeric_expression_exponentiate", - "type=NUMERIC_EXPRESSION", - "text=^1", - "expErr=Is there a number or a variable missing before or after the exponentiation symbol" + - " '^'? If not, please remove the extra '^'." - ), - Iteration( - "algebraic_expression_add", - "type=ALGEBRAIC_EXPRESSION", - "text=+x", - "expErr=Is there a number or a variable missing before or after the addition symbol '+'? If" + - " not, please remove the extra '+'." - ), - Iteration( - "algebraic_expression_multiply", - "type=ALGEBRAIC_EXPRESSION", - "text=×x", - "expErr=Is there a number or a variable missing before or after the multiplication symbol" + - " '×'? If not, please remove the extra '×'." - ), - Iteration( - "algebraic_expression_divide", - "type=ALGEBRAIC_EXPRESSION", - "text=÷x", - "expErr=Is there a number or a variable missing before or after the division symbol '÷'? If" + - " not, please remove the extra '÷'." - ), - Iteration( - "algebraic_expression_exponentiate", - "type=ALGEBRAIC_EXPRESSION", - "text=^x", - "expErr=Is there a number or a variable missing before or after the exponentiation symbol" + - " '^'? If not, please remove the extra '^'." - ), - Iteration( - "math_equation_add", - "type=MATH_EQUATION", - "text=y=+x", - "expErr=Is there a number or a variable missing before or after the addition symbol '+'? If" + - " not, please remove the extra '+'." - ), - Iteration( - "math_equation_multiply", - "type=MATH_EQUATION", - "text=y=×x", - "expErr=Is there a number or a variable missing before or after the multiplication symbol" + - " '×'? If not, please remove the extra '×'." - ), - Iteration( - "math_equation_divide", - "type=MATH_EQUATION", - "text=y=÷x", - "expErr=Is there a number or a variable missing before or after the division symbol '÷'? If" + - " not, please remove the extra '÷'." - ), - Iteration( - "math_equation_exponentiate", - "type=MATH_EQUATION", - "text=y=^x", - "expErr=Is there a number or a variable missing before or after the exponentiation symbol" + - " '^'? If not, please remove the extra '^'." - ) + @Iteration( + "numeric_expression_add", + "type=NUMERIC_EXPRESSION", + "text=+1", + "expErr=Is there a number or a variable missing before or after the addition symbol '+'? If" + + " not, please remove the extra '+'." + ) + @Iteration( + "numeric_expression_multiply", + "type=NUMERIC_EXPRESSION", + "text=×1", + "expErr=Is there a number or a variable missing before or after the multiplication symbol" + + " '×'? If not, please remove the extra '×'." + ) + @Iteration( + "numeric_expression_divide", + "type=NUMERIC_EXPRESSION", + "text=÷1", + "expErr=Is there a number or a variable missing before or after the division symbol '÷'? If" + + " not, please remove the extra '÷'." + ) + @Iteration( + "numeric_expression_exponentiate", + "type=NUMERIC_EXPRESSION", + "text=^1", + "expErr=Is there a number or a variable missing before or after the exponentiation symbol" + + " '^'? If not, please remove the extra '^'." + ) + @Iteration( + "algebraic_expression_add", + "type=ALGEBRAIC_EXPRESSION", + "text=+x", + "expErr=Is there a number or a variable missing before or after the addition symbol '+'? If" + + " not, please remove the extra '+'." + ) + @Iteration( + "algebraic_expression_multiply", + "type=ALGEBRAIC_EXPRESSION", + "text=×x", + "expErr=Is there a number or a variable missing before or after the multiplication symbol" + + " '×'? If not, please remove the extra '×'." + ) + @Iteration( + "algebraic_expression_divide", + "type=ALGEBRAIC_EXPRESSION", + "text=÷x", + "expErr=Is there a number or a variable missing before or after the division symbol '÷'? If" + + " not, please remove the extra '÷'." + ) + @Iteration( + "algebraic_expression_exponentiate", + "type=ALGEBRAIC_EXPRESSION", + "text=^x", + "expErr=Is there a number or a variable missing before or after the exponentiation symbol" + + " '^'? If not, please remove the extra '^'." + ) + @Iteration( + "math_equation_add", + "type=MATH_EQUATION", + "text=y=+x", + "expErr=Is there a number or a variable missing before or after the addition symbol '+'? If" + + " not, please remove the extra '+'." + ) + @Iteration( + "math_equation_multiply", + "type=MATH_EQUATION", + "text=y=×x", + "expErr=Is there a number or a variable missing before or after the multiplication symbol" + + " '×'? If not, please remove the extra '×'." + ) + @Iteration( + "math_equation_divide", + "type=MATH_EQUATION", + "text=y=÷x", + "expErr=Is there a number or a variable missing before or after the division symbol '÷'? If" + + " not, please remove the extra '÷'." + ) + @Iteration( + "math_equation_exponentiate", + "type=MATH_EQUATION", + "text=y=^x", + "expErr=Is there a number or a variable missing before or after the exponentiation symbol" + + " '^'? If not, please remove the extra '^'." ) fun testView_allInteractions_noVarOrNumberBeforeBinaryOpted_producesError() { val interactionType = MathInteractionType.valueOf(type) @@ -1537,10 +1492,8 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("algebraic_expression", "type=ALGEBRAIC_EXPRESSION", "text=x2"), - Iteration("math_equation", "type=MATH_EQUATION", "text=y=x2") - ) + @Iteration("algebraic_expression", "type=ALGEBRAIC_EXPRESSION", "text=x2") + @Iteration("math_equation", "type=MATH_EQUATION", "text=y=x2") fun testView_algebraicInteractions_numberAfterVariable_producesError() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() @@ -1558,11 +1511,9 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_expression", "type=NUMERIC_EXPRESSION", "text=1×÷2"), - Iteration("algebraic_expression", "type=ALGEBRAIC_EXPRESSION", "text=x×÷y"), - Iteration("math_equation", "type=MATH_EQUATION", "text=z=x×÷y") - ) + @Iteration("numeric_expression", "type=NUMERIC_EXPRESSION", "text=1×÷2") + @Iteration("algebraic_expression", "type=ALGEBRAIC_EXPRESSION", "text=x×÷y") + @Iteration("math_equation", "type=MATH_EQUATION", "text=z=x×÷y") fun testView_allInteractions_consecutiveBinaryOperators_producesError() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() @@ -1580,11 +1531,9 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_expression", "type=NUMERIC_EXPRESSION", "text=2!"), - Iteration("algebraic_expression", "type=ALGEBRAIC_EXPRESSION", "text=x!"), - Iteration("math_equation", "type=MATH_EQUATION", "text=z=x!") - ) + @Iteration("numeric_expression", "type=NUMERIC_EXPRESSION", "text=2!") + @Iteration("algebraic_expression", "type=ALGEBRAIC_EXPRESSION", "text=x!") + @Iteration("math_equation", "type=MATH_EQUATION", "text=z=x!") fun testView_allInteractions_invalidSymbol_producesError() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() @@ -1603,25 +1552,23 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration( - "algebraic_expression", - "type=ALGEBRAIC_EXPRESSION", - "text=x+y", - "expErr=Please use the variables specified in the question and not x, y." - ), - Iteration( - "math_equation_single_var_lhs", - "type=MATH_EQUATION", - "text=z=x+y", - "expErr=Please use the variables specified in the question and not z." - ), - Iteration( - "math_equation_single_var_rhs", - "type=MATH_EQUATION", - "text=x+y=z", - "expErr=Please use the variables specified in the question and not x, y." - ) + @Iteration( + "algebraic_expression", + "type=ALGEBRAIC_EXPRESSION", + "text=x+y", + "expErr=Please use the variables specified in the question and not x, y." + ) + @Iteration( + "math_equation_single_var_lhs", + "type=MATH_EQUATION", + "text=z=x+y", + "expErr=Please use the variables specified in the question and not z." + ) + @Iteration( + "math_equation_single_var_rhs", + "type=MATH_EQUATION", + "text=x+y=z", + "expErr=Please use the variables specified in the question and not x, y." ) fun testView_algebraicInteractions_missingVariables_producesError() { val interactionType = MathInteractionType.valueOf(type) @@ -1639,11 +1586,9 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_expression", "type=NUMERIC_EXPRESSION", "text=1+2"), - Iteration("algebraic_expression", "type=ALGEBRAIC_EXPRESSION", "text=x+y"), - Iteration("math_equation", "type=MATH_EQUATION", "text=z=x+y") - ) + @Iteration("numeric_expression", "type=NUMERIC_EXPRESSION", "text=1+2") + @Iteration("algebraic_expression", "type=ALGEBRAIC_EXPRESSION", "text=x+y") + @Iteration("math_equation", "type=MATH_EQUATION", "text=z=x+y") fun testView_allInteractions_validExpression_doesNotProduceSubmitTimeErrorError() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() @@ -1660,12 +1605,13 @@ class MathExpressionInteractionsViewTest { } @Test - @RunParameterized( - Iteration("numeric_expression", "type=NUMERIC_EXPRESSION", "text="), - Iteration("algebraic_expression", "type=ALGEBRAIC_EXPRESSION", "text="), - Iteration("math_equation", "type=MATH_EQUATION", "text=") - ) - fun testView_allInteractions_blankInput_produceSubmitTimeError() { + @Iteration("numeric_expression_valid", "type=NUMERIC_EXPRESSION", "text=0/1") + @Iteration("numeric_expression_invalid", "type=NUMERIC_EXPRESSION", "text=1/0") + @Iteration("algebraic_expression_valid", "type=ALGEBRAIC_EXPRESSION", "text=x^2") + @Iteration("algebraic_expression_invalid", "type=ALGEBRAIC_EXPRESSION", "text=2^x") + @Iteration("math_equation_valid", "type=MATH_EQUATION", "text=z=x^2") + @Iteration("math_equation_invalid", "type=MATH_EQUATION", "text=z=2^x") + fun testView_allInteractions_validAndInvalidExpressions_doNotProduceRealTimeError() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() launch(interactionType, interaction).use { scenario -> @@ -1674,22 +1620,17 @@ class MathExpressionInteractionsViewTest { typeExpressionInput(text) scenario.onActivity { activity -> - val answerError = activity.mathExpressionViewModel.checkPendingAnswerError(SUBMIT_TIME) - assertThat(answerError).isNotEmpty() + val answerError = activity.mathExpressionViewModel.checkPendingAnswerError(REAL_TIME) + assertThat(answerError).isNull() } } } @Test - @RunParameterized( - Iteration("numeric_expression_valid", "type=NUMERIC_EXPRESSION", "text=0/1"), - Iteration("numeric_expression_invalid", "type=NUMERIC_EXPRESSION", "text=1/0"), - Iteration("algebraic_expression_valid", "type=ALGEBRAIC_EXPRESSION", "text=x^2"), - Iteration("algebraic_expression_invalid", "type=ALGEBRAIC_EXPRESSION", "text=2^x"), - Iteration("math_equation_valid", "type=MATH_EQUATION", "text=z=x^2"), - Iteration("math_equation_invalid", "type=MATH_EQUATION", "text=z=2^x") - ) - fun testView_allInteractions_validAndInvalidExpressions_doNotProduceRealTimeError() { + @Iteration("numeric_expression", "type=NUMERIC_EXPRESSION", "text=") + @Iteration("algebraic_expression", "type=ALGEBRAIC_EXPRESSION", "text=") + @Iteration("math_equation", "type=MATH_EQUATION", "text=") + fun testView_allInteractions_blankInput_produceSubmitTimeError() { val interactionType = MathInteractionType.valueOf(type) val interaction = createInteraction() launch(interactionType, interaction).use { scenario -> @@ -1697,9 +1638,10 @@ class MathExpressionInteractionsViewTest { typeExpressionInput(text) + // Using not-allowed-listed variables should result in a failure. scenario.onActivity { activity -> - val answerError = activity.mathExpressionViewModel.checkPendingAnswerError(REAL_TIME) - assertThat(answerError).isNull() + val answerError = activity.mathExpressionViewModel.checkPendingAnswerError(SUBMIT_TIME) + assertThat(answerError).isNotEmpty() } } } diff --git a/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt index 9fffcb5bb70..484a9696142 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/splash/SplashActivityTest.kt @@ -101,7 +101,6 @@ import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedAutoAndroidTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -425,12 +424,10 @@ class SplashActivityTest { } @Test - @RunParameterized( - Iteration("testing_to_beta", "firstOpen=TESTING", "secondOpen=BETA"), - Iteration("dev_to_beta", "firstOpen=DEVELOPER", "secondOpen=BETA"), - Iteration("alpha_to_beta", "firstOpen=ALPHA", "secondOpen=BETA"), - Iteration("ga_to_beta", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=BETA") - ) + @Iteration("testing_to_beta", "firstOpen=TESTING", "secondOpen=BETA") + @Iteration("dev_to_beta", "firstOpen=DEVELOPER", "secondOpen=BETA") + @Iteration("alpha_to_beta", "firstOpen=ALPHA", "secondOpen=BETA") + @Iteration("ga_to_beta", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=BETA") fun testSplashActivity_newUser_betaFlavorTransitions_showsBetaNotice() { simulateAppAlreadyOpenedWithFlavor(firstOpenFlavor) @@ -443,12 +440,10 @@ class SplashActivityTest { } @Test - @RunParameterized( - Iteration("testing_to_beta", "firstOpen=TESTING", "secondOpen=BETA"), - Iteration("dev_to_beta", "firstOpen=DEVELOPER", "secondOpen=BETA"), - Iteration("alpha_to_beta", "firstOpen=ALPHA", "secondOpen=BETA"), - Iteration("ga_to_beta", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=BETA") - ) + @Iteration("testing_to_beta", "firstOpen=TESTING", "secondOpen=BETA") + @Iteration("dev_to_beta", "firstOpen=DEVELOPER", "secondOpen=BETA") + @Iteration("alpha_to_beta", "firstOpen=ALPHA", "secondOpen=BETA") + @Iteration("ga_to_beta", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=BETA") fun testSplashActivity_newUser_betaFlavorTransitions_closeNotice_routesToOnboardingFlow() { simulateAppAlreadyOpenedWithFlavor(firstOpenFlavor) initializeTestApplicationWithFlavor(secondOpenFlavor) @@ -464,12 +459,10 @@ class SplashActivityTest { } @Test - @RunParameterized( - Iteration("testing_to_beta", "firstOpen=TESTING", "secondOpen=BETA"), - Iteration("dev_to_beta", "firstOpen=DEVELOPER", "secondOpen=BETA"), - Iteration("alpha_to_beta", "firstOpen=ALPHA", "secondOpen=BETA"), - Iteration("ga_to_beta", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=BETA") - ) + @Iteration("testing_to_beta", "firstOpen=TESTING", "secondOpen=BETA") + @Iteration("dev_to_beta", "firstOpen=DEVELOPER", "secondOpen=BETA") + @Iteration("alpha_to_beta", "firstOpen=ALPHA", "secondOpen=BETA") + @Iteration("ga_to_beta", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=BETA") fun testSplashActivity_newUser_betaFlavorTransitions_doNotShowAgain_routesToOnboardingFlow() { simulateAppAlreadyOpenedWithFlavor(firstOpenFlavor) initializeTestApplicationWithFlavor(secondOpenFlavor) @@ -564,10 +557,8 @@ class SplashActivityTest { } @Test - @RunParameterized( - Iteration("alpha_to_ga", "firstOpen=ALPHA", "secondOpen=GENERAL_AVAILABILITY"), - Iteration("beta_to_ga", "firstOpen=BETA", "secondOpen=GENERAL_AVAILABILITY") - ) + @Iteration("alpha_to_ga", "firstOpen=ALPHA", "secondOpen=GENERAL_AVAILABILITY") + @Iteration("beta_to_ga", "firstOpen=BETA", "secondOpen=GENERAL_AVAILABILITY") fun testSplashActivity_onboarded_gaFlavorTransitions_showsGaUpgradeNotice() { simulateAppAlreadyOnboardedWithFlavor(firstOpenFlavor) @@ -581,10 +572,8 @@ class SplashActivityTest { } @Test - @RunParameterized( - Iteration("alpha_to_ga", "firstOpen=ALPHA", "secondOpen=GENERAL_AVAILABILITY"), - Iteration("beta_to_ga", "firstOpen=BETA", "secondOpen=GENERAL_AVAILABILITY") - ) + @Iteration("alpha_to_ga", "firstOpen=ALPHA", "secondOpen=GENERAL_AVAILABILITY") + @Iteration("beta_to_ga", "firstOpen=BETA", "secondOpen=GENERAL_AVAILABILITY") fun testSplashActivity_onboarded_gaFlavorTransitions_closeNotice_routesToProfileChooser() { simulateAppAlreadyOnboardedWithFlavor(firstOpenFlavor) initializeTestApplicationWithFlavor(secondOpenFlavor) @@ -601,10 +590,8 @@ class SplashActivityTest { } @Test - @RunParameterized( - Iteration("alpha_to_ga", "firstOpen=ALPHA", "secondOpen=GENERAL_AVAILABILITY"), - Iteration("beta_to_ga", "firstOpen=BETA", "secondOpen=GENERAL_AVAILABILITY") - ) + @Iteration("alpha_to_ga", "firstOpen=ALPHA", "secondOpen=GENERAL_AVAILABILITY") + @Iteration("beta_to_ga", "firstOpen=BETA", "secondOpen=GENERAL_AVAILABILITY") fun testSplashActivity_onboarded_gaFlavorTransitions_doNotShowAgain_routesToProfileChooser() { simulateAppAlreadyOnboardedWithFlavor(firstOpenFlavor) initializeTestApplicationWithFlavor(secondOpenFlavor) @@ -774,27 +761,25 @@ class SplashActivityTest { } @Test - @RunParameterized( - Iteration("testing_to_testing", "firstOpen=TESTING", "secondOpen=TESTING"), - Iteration("testing_to_dev", "firstOpen=TESTING", "secondOpen=DEVELOPER"), - Iteration("testing_to_alpha", "firstOpen=TESTING", "secondOpen=ALPHA"), - Iteration("testing_to_ga", "firstOpen=TESTING", "secondOpen=GENERAL_AVAILABILITY"), - Iteration("dev_to_testing", "firstOpen=DEVELOPER", "secondOpen=TESTING"), - Iteration("dev_to_dev", "firstOpen=DEVELOPER", "secondOpen=DEVELOPER"), - Iteration("dev_to_alpha", "firstOpen=DEVELOPER", "secondOpen=ALPHA"), - Iteration("dev_to_ga", "firstOpen=DEVELOPER", "secondOpen=GENERAL_AVAILABILITY"), - Iteration("alpha_to_testing", "firstOpen=ALPHA", "secondOpen=TESTING"), - Iteration("alpha_to_dev", "firstOpen=ALPHA", "secondOpen=DEVELOPER"), - Iteration("alpha_to_alpha", "firstOpen=ALPHA", "secondOpen=ALPHA"), - Iteration("beta_to_testing", "firstOpen=BETA", "secondOpen=TESTING"), - Iteration("beta_to_dev", "firstOpen=BETA", "secondOpen=DEVELOPER"), - Iteration("beta_to_alpha", "firstOpen=BETA", "secondOpen=ALPHA"), - Iteration("beta_to_beta", "firstOpen=BETA", "secondOpen=BETA"), - Iteration("ga_to_testing", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=TESTING"), - Iteration("ga_to_dev", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=DEVELOPER"), - Iteration("ga_to_alpha", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=ALPHA"), - Iteration("ga_to_ga", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=GENERAL_AVAILABILITY") - ) + @Iteration("testing_to_testing", "firstOpen=TESTING", "secondOpen=TESTING") + @Iteration("testing_to_dev", "firstOpen=TESTING", "secondOpen=DEVELOPER") + @Iteration("testing_to_alpha", "firstOpen=TESTING", "secondOpen=ALPHA") + @Iteration("testing_to_ga", "firstOpen=TESTING", "secondOpen=GENERAL_AVAILABILITY") + @Iteration("dev_to_testing", "firstOpen=DEVELOPER", "secondOpen=TESTING") + @Iteration("dev_to_dev", "firstOpen=DEVELOPER", "secondOpen=DEVELOPER") + @Iteration("dev_to_alpha", "firstOpen=DEVELOPER", "secondOpen=ALPHA") + @Iteration("dev_to_ga", "firstOpen=DEVELOPER", "secondOpen=GENERAL_AVAILABILITY") + @Iteration("alpha_to_testing", "firstOpen=ALPHA", "secondOpen=TESTING") + @Iteration("alpha_to_dev", "firstOpen=ALPHA", "secondOpen=DEVELOPER") + @Iteration("alpha_to_alpha", "firstOpen=ALPHA", "secondOpen=ALPHA") + @Iteration("beta_to_testing", "firstOpen=BETA", "secondOpen=TESTING") + @Iteration("beta_to_dev", "firstOpen=BETA", "secondOpen=DEVELOPER") + @Iteration("beta_to_alpha", "firstOpen=BETA", "secondOpen=ALPHA") + @Iteration("beta_to_beta", "firstOpen=BETA", "secondOpen=BETA") + @Iteration("ga_to_testing", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=TESTING") + @Iteration("ga_to_dev", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=DEVELOPER") + @Iteration("ga_to_alpha", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=ALPHA") + @Iteration("ga_to_ga", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=GENERAL_AVAILABILITY") fun testSplashActivity_newUser_ignoredFlavorTransitions_routesToOnboardingFlow() { simulateAppAlreadyOpenedWithFlavor(firstOpenFlavor) @@ -808,27 +793,25 @@ class SplashActivityTest { } @Test - @RunParameterized( - Iteration("testing_to_testing", "firstOpen=TESTING", "secondOpen=TESTING"), - Iteration("testing_to_dev", "firstOpen=TESTING", "secondOpen=DEVELOPER"), - Iteration("testing_to_alpha", "firstOpen=TESTING", "secondOpen=ALPHA"), - Iteration("testing_to_ga", "firstOpen=TESTING", "secondOpen=GENERAL_AVAILABILITY"), - Iteration("dev_to_testing", "firstOpen=DEVELOPER", "secondOpen=TESTING"), - Iteration("dev_to_dev", "firstOpen=DEVELOPER", "secondOpen=DEVELOPER"), - Iteration("dev_to_alpha", "firstOpen=DEVELOPER", "secondOpen=ALPHA"), - Iteration("dev_to_ga", "firstOpen=DEVELOPER", "secondOpen=GENERAL_AVAILABILITY"), - Iteration("alpha_to_testing", "firstOpen=ALPHA", "secondOpen=TESTING"), - Iteration("alpha_to_dev", "firstOpen=ALPHA", "secondOpen=DEVELOPER"), - Iteration("alpha_to_alpha", "firstOpen=ALPHA", "secondOpen=ALPHA"), - Iteration("beta_to_testing", "firstOpen=BETA", "secondOpen=TESTING"), - Iteration("beta_to_dev", "firstOpen=BETA", "secondOpen=DEVELOPER"), - Iteration("beta_to_alpha", "firstOpen=BETA", "secondOpen=ALPHA"), - Iteration("beta_to_beta", "firstOpen=BETA", "secondOpen=BETA"), - Iteration("ga_to_testing", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=TESTING"), - Iteration("ga_to_dev", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=DEVELOPER"), - Iteration("ga_to_alpha", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=ALPHA"), - Iteration("ga_to_ga", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=GENERAL_AVAILABILITY") - ) + @Iteration("testing_to_testing", "firstOpen=TESTING", "secondOpen=TESTING") + @Iteration("testing_to_dev", "firstOpen=TESTING", "secondOpen=DEVELOPER") + @Iteration("testing_to_alpha", "firstOpen=TESTING", "secondOpen=ALPHA") + @Iteration("testing_to_ga", "firstOpen=TESTING", "secondOpen=GENERAL_AVAILABILITY") + @Iteration("dev_to_testing", "firstOpen=DEVELOPER", "secondOpen=TESTING") + @Iteration("dev_to_dev", "firstOpen=DEVELOPER", "secondOpen=DEVELOPER") + @Iteration("dev_to_alpha", "firstOpen=DEVELOPER", "secondOpen=ALPHA") + @Iteration("dev_to_ga", "firstOpen=DEVELOPER", "secondOpen=GENERAL_AVAILABILITY") + @Iteration("alpha_to_testing", "firstOpen=ALPHA", "secondOpen=TESTING") + @Iteration("alpha_to_dev", "firstOpen=ALPHA", "secondOpen=DEVELOPER") + @Iteration("alpha_to_alpha", "firstOpen=ALPHA", "secondOpen=ALPHA") + @Iteration("beta_to_testing", "firstOpen=BETA", "secondOpen=TESTING") + @Iteration("beta_to_dev", "firstOpen=BETA", "secondOpen=DEVELOPER") + @Iteration("beta_to_alpha", "firstOpen=BETA", "secondOpen=ALPHA") + @Iteration("beta_to_beta", "firstOpen=BETA", "secondOpen=BETA") + @Iteration("ga_to_testing", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=TESTING") + @Iteration("ga_to_dev", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=DEVELOPER") + @Iteration("ga_to_alpha", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=ALPHA") + @Iteration("ga_to_ga", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=GENERAL_AVAILABILITY") fun testSplashActivity_onboarded_ignoredFlavorTransitions_routesToProfileChooser() { simulateAppAlreadyOnboardedWithFlavor(firstOpenFlavor) @@ -842,33 +825,31 @@ class SplashActivityTest { } @Test - @RunParameterized( - Iteration("testing_to_testing", "firstOpen=TESTING", "secondOpen=TESTING"), - Iteration("testing_to_dev", "firstOpen=TESTING", "secondOpen=DEVELOPER"), - Iteration("testing_to_alpha", "firstOpen=TESTING", "secondOpen=ALPHA"), - Iteration("testing_to_beta", "firstOpen=TESTING", "secondOpen=BETA"), - Iteration("testing_to_ga", "firstOpen=TESTING", "secondOpen=GENERAL_AVAILABILITY"), - Iteration("dev_to_testing", "firstOpen=DEVELOPER", "secondOpen=TESTING"), - Iteration("dev_to_dev", "firstOpen=DEVELOPER", "secondOpen=DEVELOPER"), - Iteration("dev_to_alpha", "firstOpen=DEVELOPER", "secondOpen=ALPHA"), - Iteration("dev_to_beta", "firstOpen=DEVELOPER", "secondOpen=BETA"), - Iteration("dev_to_ga", "firstOpen=DEVELOPER", "secondOpen=GENERAL_AVAILABILITY"), - Iteration("alpha_to_testing", "firstOpen=ALPHA", "secondOpen=TESTING"), - Iteration("alpha_to_dev", "firstOpen=ALPHA", "secondOpen=DEVELOPER"), - Iteration("alpha_to_alpha", "firstOpen=ALPHA", "secondOpen=ALPHA"), - Iteration("alpha_to_beta", "firstOpen=ALPHA", "secondOpen=BETA"), - Iteration("alpha_to_ga", "firstOpen=ALPHA", "secondOpen=GENERAL_AVAILABILITY"), - Iteration("beta_to_testing", "firstOpen=BETA", "secondOpen=TESTING"), - Iteration("beta_to_dev", "firstOpen=BETA", "secondOpen=DEVELOPER"), - Iteration("beta_to_alpha", "firstOpen=BETA", "secondOpen=ALPHA"), - Iteration("beta_to_beta", "firstOpen=BETA", "secondOpen=BETA"), - Iteration("beta_to_ga", "firstOpen=BETA", "secondOpen=GENERAL_AVAILABILITY"), - Iteration("ga_to_testing", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=TESTING"), - Iteration("ga_to_dev", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=DEVELOPER"), - Iteration("ga_to_alpha", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=ALPHA"), - Iteration("ga_to_beta", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=BETA"), - Iteration("ga_to_ga", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=GENERAL_AVAILABILITY") - ) + @Iteration("testing_to_testing", "firstOpen=TESTING", "secondOpen=TESTING") + @Iteration("testing_to_dev", "firstOpen=TESTING", "secondOpen=DEVELOPER") + @Iteration("testing_to_alpha", "firstOpen=TESTING", "secondOpen=ALPHA") + @Iteration("testing_to_beta", "firstOpen=TESTING", "secondOpen=BETA") + @Iteration("testing_to_ga", "firstOpen=TESTING", "secondOpen=GENERAL_AVAILABILITY") + @Iteration("dev_to_testing", "firstOpen=DEVELOPER", "secondOpen=TESTING") + @Iteration("dev_to_dev", "firstOpen=DEVELOPER", "secondOpen=DEVELOPER") + @Iteration("dev_to_alpha", "firstOpen=DEVELOPER", "secondOpen=ALPHA") + @Iteration("dev_to_beta", "firstOpen=DEVELOPER", "secondOpen=BETA") + @Iteration("dev_to_ga", "firstOpen=DEVELOPER", "secondOpen=GENERAL_AVAILABILITY") + @Iteration("alpha_to_testing", "firstOpen=ALPHA", "secondOpen=TESTING") + @Iteration("alpha_to_dev", "firstOpen=ALPHA", "secondOpen=DEVELOPER") + @Iteration("alpha_to_alpha", "firstOpen=ALPHA", "secondOpen=ALPHA") + @Iteration("alpha_to_beta", "firstOpen=ALPHA", "secondOpen=BETA") + @Iteration("alpha_to_ga", "firstOpen=ALPHA", "secondOpen=GENERAL_AVAILABILITY") + @Iteration("beta_to_testing", "firstOpen=BETA", "secondOpen=TESTING") + @Iteration("beta_to_dev", "firstOpen=BETA", "secondOpen=DEVELOPER") + @Iteration("beta_to_alpha", "firstOpen=BETA", "secondOpen=ALPHA") + @Iteration("beta_to_beta", "firstOpen=BETA", "secondOpen=BETA") + @Iteration("beta_to_ga", "firstOpen=BETA", "secondOpen=GENERAL_AVAILABILITY") + @Iteration("ga_to_testing", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=TESTING") + @Iteration("ga_to_dev", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=DEVELOPER") + @Iteration("ga_to_alpha", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=ALPHA") + @Iteration("ga_to_beta", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=BETA") + @Iteration("ga_to_ga", "firstOpen=GENERAL_AVAILABILITY", "secondOpen=GENERAL_AVAILABILITY") fun testSplashActivity_appDeprecated_allFlavorTransitions_showsDeprecationNotice() { simulateAppAlreadyOnboardedWithFlavor(firstOpenFlavor) diff --git a/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt b/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt index de2af63d445..76811f7f5b3 100644 --- a/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt +++ b/app/src/test/java/org/oppia/android/app/translation/AppLanguageResourceHandlerTest.kt @@ -73,7 +73,6 @@ import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -494,18 +493,16 @@ class AppLanguageResourceHandlerTest { // testing functionality that's expected to go away with later language selection work. // TODO(#3793): Remove this once OppiaLanguage is used as the source of truth. @Test - @RunParameterized( - Iteration("hi", "lang=HINDI_AUDIO_LANGUAGE", "expectedDisplayText=हिन्दी"), - Iteration("fr", "lang=FRENCH_AUDIO_LANGUAGE", "expectedDisplayText=Français"), - Iteration("zh", "lang=CHINESE_AUDIO_LANGUAGE", "expectedDisplayText=中文"), - Iteration("pr-pt", "lang=BRAZILIAN_PORTUGUESE_LANGUAGE", "expectedDisplayText=Português"), - Iteration("ar", "lang=ARABIC_LANGUAGE", "expectedDisplayText=العربية"), - Iteration("pcm", "lang=NIGERIAN_PIDGIN_LANGUAGE", "expectedDisplayText=Naijá"), - Iteration("unsp", "lang=AUDIO_LANGUAGE_UNSPECIFIED", "expectedDisplayText=English"), - Iteration("none", "lang=NO_AUDIO", "expectedDisplayText=English"), - Iteration("unknown", "lang=UNRECOGNIZED", "expectedDisplayText=English"), - Iteration("en", "lang=ENGLISH_AUDIO_LANGUAGE", "expectedDisplayText=English") - ) + @Iteration("hi", "lang=HINDI_AUDIO_LANGUAGE", "expectedDisplayText=हिन्दी") + @Iteration("fr", "lang=FRENCH_AUDIO_LANGUAGE", "expectedDisplayText=Français") + @Iteration("zh", "lang=CHINESE_AUDIO_LANGUAGE", "expectedDisplayText=中文") + @Iteration("pr-pt", "lang=BRAZILIAN_PORTUGUESE_LANGUAGE", "expectedDisplayText=Português") + @Iteration("ar", "lang=ARABIC_LANGUAGE", "expectedDisplayText=العربية") + @Iteration("pcm", "lang=NIGERIAN_PIDGIN_LANGUAGE", "expectedDisplayText=Naijá") + @Iteration("unsp", "lang=AUDIO_LANGUAGE_UNSPECIFIED", "expectedDisplayText=English") + @Iteration("none", "lang=NO_AUDIO", "expectedDisplayText=English") + @Iteration("unknown", "lang=UNRECOGNIZED", "expectedDisplayText=English") + @Iteration("en", "lang=ENGLISH_AUDIO_LANGUAGE", "expectedDisplayText=English") fun testComputeLocalizedDisplayName_englishLocale_forAllLanguages_hasTheExpectedOutput() { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() @@ -517,17 +514,15 @@ class AppLanguageResourceHandlerTest { } @Test - @RunParameterized( - Iteration("unknown", "lang=LANGUAGE_UNSPECIFIED", "expectedDisplayText=English"), - Iteration("ar", "lang=ARABIC", "expectedDisplayText=العربية"), - Iteration("en", "lang=ENGLISH", "expectedDisplayText=English"), - Iteration("hi", "lang=HINDI", "expectedDisplayText=हिन्दी"), - Iteration("hi-en", "lang=HINGLISH", "expectedDisplayText=हिन्दी"), - Iteration("pt", "lang=PORTUGUESE", "expectedDisplayText=Português"), - Iteration("pr-pt", "lang=BRAZILIAN_PORTUGUESE", "expectedDisplayText=Português"), - Iteration("sw", "lang=SWAHILI", "expectedDisplayText=Kiswahili"), - Iteration("pcm", "lang=NIGERIAN_PIDGIN", "expectedDisplayText=Naijá") - ) + @Iteration("unknown", "lang=LANGUAGE_UNSPECIFIED", "expectedDisplayText=English") + @Iteration("ar", "lang=ARABIC", "expectedDisplayText=العربية") + @Iteration("en", "lang=ENGLISH", "expectedDisplayText=English") + @Iteration("hi", "lang=HINDI", "expectedDisplayText=हिन्दी") + @Iteration("hi-en", "lang=HINGLISH", "expectedDisplayText=हिन्दी") + @Iteration("pt", "lang=PORTUGUESE", "expectedDisplayText=Português") + @Iteration("pr-pt", "lang=BRAZILIAN_PORTUGUESE", "expectedDisplayText=Português") + @Iteration("sw", "lang=SWAHILI", "expectedDisplayText=Kiswahili") + @Iteration("pcm", "lang=NIGERIAN_PIDGIN", "expectedDisplayText=Naijá") fun testComputeLocalizedDisplayName_englishLocale_forAllDisplayLanguages_hasTheExpectedOutput() { updateAppLanguageTo(OppiaLanguage.ENGLISH) val handler = retrieveAppLanguageResourceHandler() diff --git a/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt b/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt index 3ad3164a1b1..628b7cb8b75 100644 --- a/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt +++ b/app/src/test/java/org/oppia/android/app/utility/math/MathExpressionAccessibilityUtilTest.kt @@ -83,7 +83,6 @@ import org.oppia.android.testing.junit.InitializeDefaultLocaleRule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.math.MathEquationSubject @@ -169,17 +168,15 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("LANGUAGE_UNSPECIFIED", "language=LANGUAGE_UNSPECIFIED"), - Iteration("ARABIC", "language=ARABIC"), - Iteration("HINDI", "language=HINDI"), - Iteration("HINGLISH", "language=HINGLISH"), - Iteration("PORTUGUESE", "language=PORTUGUESE"), - Iteration("BRAZILIAN_PORTUGUESE", "language=BRAZILIAN_PORTUGUESE"), - Iteration("SWAHILI", "language=SWAHILI"), - Iteration("NIGERIAN_PIDGIN", "language=NIGERIAN_PIDGIN"), - Iteration("UNRECOGNIZED", "language=UNRECOGNIZED") - ) + @Iteration("LANGUAGE_UNSPECIFIED", "language=LANGUAGE_UNSPECIFIED") + @Iteration("ARABIC", "language=ARABIC") + @Iteration("HINDI", "language=HINDI") + @Iteration("HINGLISH", "language=HINGLISH") + @Iteration("PORTUGUESE", "language=PORTUGUESE") + @Iteration("BRAZILIAN_PORTUGUESE", "language=BRAZILIAN_PORTUGUESE") + @Iteration("SWAHILI", "language=SWAHILI") + @Iteration("NIGERIAN_PIDGIN", "language=NIGERIAN_PIDGIN") + @Iteration("UNRECOGNIZED", "language=UNRECOGNIZED") fun testConvertToString_constExp_unsupportedLanguage_returnsNull() { val exp = parseAlgebraicExpression("2") val language = OppiaLanguage.valueOf(language) @@ -188,17 +185,15 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("LANGUAGE_UNSPECIFIED", "language=LANGUAGE_UNSPECIFIED"), - Iteration("ARABIC", "language=ARABIC"), - Iteration("HINDI", "language=HINDI"), - Iteration("HINGLISH", "language=HINGLISH"), - Iteration("PORTUGUESE", "language=PORTUGUESE"), - Iteration("BRAZILIAN_PORTUGUESE", "language=BRAZILIAN_PORTUGUESE"), - Iteration("SWAHILI", "language=SWAHILI"), - Iteration("NIGERIAN_PIDGIN", "language=NIGERIAN_PIDGIN"), - Iteration("UNRECOGNIZED", "language=UNRECOGNIZED") - ) + @Iteration("LANGUAGE_UNSPECIFIED", "language=LANGUAGE_UNSPECIFIED") + @Iteration("ARABIC", "language=ARABIC") + @Iteration("HINDI", "language=HINDI") + @Iteration("HINGLISH", "language=HINGLISH") + @Iteration("PORTUGUESE", "language=PORTUGUESE") + @Iteration("BRAZILIAN_PORTUGUESE", "language=BRAZILIAN_PORTUGUESE") + @Iteration("SWAHILI", "language=SWAHILI") + @Iteration("NIGERIAN_PIDGIN", "language=NIGERIAN_PIDGIN") + @Iteration("UNRECOGNIZED", "language=UNRECOGNIZED") fun testConvertToString_constEq_unsupportedLanguage_returnsNull() { val eq = parseAlgebraicEquation("x=2") val language = OppiaLanguage.valueOf(language) @@ -220,14 +215,12 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("2", "expression=2", "a11yStr=2"), - Iteration("123", "expression=123", "a11yStr=123"), - Iteration("1234", "expression=1234", "a11yStr=1,234"), - Iteration("12345", "expression=12345", "a11yStr=12,345"), - Iteration("123456", "expression=123456", "a11yStr=123,456"), - Iteration("1234567", "expression=1234567", "a11yStr=1,234,567") - ) + @Iteration("2", "expression=2", "a11yStr=2") + @Iteration("123", "expression=123", "a11yStr=123") + @Iteration("1234", "expression=1234", "a11yStr=1,234") + @Iteration("12345", "expression=12345", "a11yStr=12,345") + @Iteration("123456", "expression=123456", "a11yStr=123,456") + @Iteration("1234567", "expression=1234567", "a11yStr=1,234,567") fun testConvertToString_eng_constIntExp_returnsIntegerConvertedString() { val exp = parseAlgebraicExpression(expression) @@ -235,23 +228,21 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - // Note that some rounding occurs when formatting doubles with decimals. - Iteration("2.0", "expression=2.0", "a11yStr=2"), - Iteration("3.14", "expression=3.14", "a11yStr=3.14"), - Iteration( - "long_pi", "expression=3.14159265358979323846264338327950288419716939937510", "a11yStr=3.142" - ), - Iteration("1234.0", "expression=1234.0", "a11yStr=1,234"), - Iteration("12345.0", "expression=12345.0", "a11yStr=12,345"), - Iteration("123456.0", "expression=123456.0", "a11yStr=123,456"), - Iteration("1234567.0", "expression=1234567.0", "a11yStr=1,234,567"), - Iteration("1234567.987654321", "expression=1234567.987654321", "a11yStr=1,234,567.988"), - // Verify that scientific notation isn't used. - Iteration("small_number", "expression=0.000000000000000000001", "a11yStr=0"), - Iteration( - "large_number", "expression=123456789101112131415.0", "a11yStr=123,456,789,101,112,130,000" - ) + // Note that some rounding occurs when formatting doubles with decimals. + @Iteration("2.0", "expression=2.0", "a11yStr=2") + @Iteration("3.14", "expression=3.14", "a11yStr=3.14") + @Iteration( + "long_pi", "expression=3.14159265358979323846264338327950288419716939937510", "a11yStr=3.142" + ) + @Iteration("1234.0", "expression=1234.0", "a11yStr=1,234") + @Iteration("12345.0", "expression=12345.0", "a11yStr=12,345") + @Iteration("123456.0", "expression=123456.0", "a11yStr=123,456") + @Iteration("1234567.0", "expression=1234567.0", "a11yStr=1,234,567") + @Iteration("1234567.987654321", "expression=1234567.987654321", "a11yStr=1,234,567.988") + // Verify that scientific notation isn't used. + @Iteration("small_number", "expression=0.000000000000000000001", "a11yStr=0") + @Iteration( + "large_number", "expression=123456789101112131415.0", "a11yStr=123,456,789,101,112,130,000" ) fun testConvertToString_eng_constDoubleExp_returnsDoubleConvertedString() { val exp = parseAlgebraicExpression(expression) @@ -260,15 +251,13 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("x", "expression=x", "a11yStr=x"), - Iteration("y", "expression=y", "a11yStr=y"), - Iteration("z", "expression=z", "a11yStr=zed"), - Iteration("X", "expression=X", "a11yStr=X"), - Iteration("Y", "expression=Y", "a11yStr=Y"), - Iteration("Z", "expression=Z", "a11yStr=Zed"), - Iteration("a", "expression=a", "a11yStr=a") - ) + @Iteration("x", "expression=x", "a11yStr=x") + @Iteration("y", "expression=y", "a11yStr=y") + @Iteration("z", "expression=z", "a11yStr=zed") + @Iteration("X", "expression=X", "a11yStr=X") + @Iteration("Y", "expression=Y", "a11yStr=Y") + @Iteration("Z", "expression=Z", "a11yStr=Zed") + @Iteration("a", "expression=a", "a11yStr=a") fun testConvertToString_eng_variableExp_returnsVariableNameWithZed() { val allowedVariables = listOf("a", "x", "y", "z", "X", "Y", "Z") val exp = parseAlgebraicExpression(expression, allowedVariables) @@ -277,13 +266,11 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("1+2", "expression=1+2", "a11yStr=1 plus 2"), - Iteration("1+x", "expression=1+x", "a11yStr=1 plus x"), - Iteration("z+1234", "expression=z+1234", "a11yStr=zed plus 1,234"), - Iteration("z+3.14", "expression=z+3.14", "a11yStr=zed plus 3.14"), - Iteration("x+z", "expression=x+z", "a11yStr=x plus zed") - ) + @Iteration("1+2", "expression=1+2", "a11yStr=1 plus 2") + @Iteration("1+x", "expression=1+x", "a11yStr=1 plus x") + @Iteration("z+1234", "expression=z+1234", "a11yStr=zed plus 1,234") + @Iteration("z+3.14", "expression=z+3.14", "a11yStr=zed plus 3.14") + @Iteration("x+z", "expression=x+z", "a11yStr=x plus zed") fun testConvertToString_eng_addition_returnsLeftPlusRightString() { val exp = parseAlgebraicExpression(expression) @@ -291,13 +278,11 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("1-2", "expression=1-2", "a11yStr=1 minus 2"), - Iteration("1-x", "expression=1-x", "a11yStr=1 minus x"), - Iteration("z-1234", "expression=z-1234", "a11yStr=zed minus 1,234"), - Iteration("z-3.14", "expression=z-3.14", "a11yStr=zed minus 3.14"), - Iteration("x-z", "expression=x-z", "a11yStr=x minus zed") - ) + @Iteration("1-2", "expression=1-2", "a11yStr=1 minus 2") + @Iteration("1-x", "expression=1-x", "a11yStr=1 minus x") + @Iteration("z-1234", "expression=z-1234", "a11yStr=zed minus 1,234") + @Iteration("z-3.14", "expression=z-3.14", "a11yStr=zed minus 3.14") + @Iteration("x-z", "expression=x-z", "a11yStr=x minus zed") fun testConvertToString_eng_subtraction_returnsLeftMinusRightString() { val exp = parseAlgebraicExpression(expression) @@ -305,13 +290,11 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("1*2", "expression=1*2", "a11yStr=1 times 2"), - Iteration("1*x", "expression=1*x", "a11yStr=1 times x"), - Iteration("z*1234", "expression=z*1234", "a11yStr=zed times 1,234"), - Iteration("z*3.14", "expression=z*3.14", "a11yStr=zed times 3.14"), - Iteration("x*z", "expression=x*z", "a11yStr=x times zed") - ) + @Iteration("1*2", "expression=1*2", "a11yStr=1 times 2") + @Iteration("1*x", "expression=1*x", "a11yStr=1 times x") + @Iteration("z*1234", "expression=z*1234", "a11yStr=zed times 1,234") + @Iteration("z*3.14", "expression=z*3.14", "a11yStr=zed times 3.14") + @Iteration("x*z", "expression=x*z", "a11yStr=x times zed") fun testConvertToString_eng_multiplication_returnsLeftTimesRightString() { val exp = parseAlgebraicExpression(expression) @@ -319,13 +302,11 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("1/2", "expression=1/2", "a11yStr=1 divided by 2"), - Iteration("1/x", "expression=1/x", "a11yStr=1 divided by x"), - Iteration("z/1234", "expression=z/1234", "a11yStr=zed divided by 1,234"), - Iteration("z/3.14", "expression=z/3.14", "a11yStr=zed divided by 3.14"), - Iteration("x/z", "expression=x/z", "a11yStr=x divided by zed") - ) + @Iteration("1/2", "expression=1/2", "a11yStr=1 divided by 2") + @Iteration("1/x", "expression=1/x", "a11yStr=1 divided by x") + @Iteration("z/1234", "expression=z/1234", "a11yStr=zed divided by 1,234") + @Iteration("z/3.14", "expression=z/3.14", "a11yStr=zed divided by 3.14") + @Iteration("x/z", "expression=x/z", "a11yStr=x divided by zed") fun testConvertToString_eng_division_returnsLeftDividedByRightString() { val exp = parseAlgebraicExpression(expression) @@ -333,13 +314,11 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("1^2", "expression=1^2", "a11yStr=1 raised to the power of 2"), - Iteration("1^x", "expression=1^x", "a11yStr=1 raised to the power of x"), - Iteration("z^1234", "expression=z^1234", "a11yStr=zed raised to the power of 1,234"), - Iteration("z^3.14", "expression=z^3.14", "a11yStr=zed raised to the power of 3.14"), - Iteration("x^z", "expression=x^z", "a11yStr=x raised to the power of zed") - ) + @Iteration("1^2", "expression=1^2", "a11yStr=1 raised to the power of 2") + @Iteration("1^x", "expression=1^x", "a11yStr=1 raised to the power of x") + @Iteration("z^1234", "expression=z^1234", "a11yStr=zed raised to the power of 1,234") + @Iteration("z^3.14", "expression=z^3.14", "a11yStr=zed raised to the power of 3.14") + @Iteration("x^z", "expression=x^z", "a11yStr=x raised to the power of zed") fun testConvertToString_eng_exponentiation_returnsLeftRaisedToThePowerOfRightString() { // Some expressions may include variable terms as exponents (which normally isn't allowed). val exp = parseAlgebraicExpression(expression, errorCheckingMode = REQUIRED_ONLY) @@ -348,13 +327,11 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("-2", "expression=-2", "a11yStr=negative 2"), - Iteration("-x", "expression=-x", "a11yStr=negative x"), - Iteration("-1234", "expression=-1234", "a11yStr=negative 1,234"), - Iteration("-3.14", "expression=-3.14", "a11yStr=negative 3.14"), - Iteration("-z", "expression=-z", "a11yStr=negative zed") - ) + @Iteration("-2", "expression=-2", "a11yStr=negative 2") + @Iteration("-x", "expression=-x", "a11yStr=negative x") + @Iteration("-1234", "expression=-1234", "a11yStr=negative 1,234") + @Iteration("-3.14", "expression=-3.14", "a11yStr=negative 3.14") + @Iteration("-z", "expression=-z", "a11yStr=negative zed") fun testConvertToString_eng_negation_returnsNegativeOperandString() { val exp = parseAlgebraicExpression(expression) @@ -362,13 +339,11 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("+2", "expression=+2", "a11yStr=positive 2"), - Iteration("+x", "expression=+x", "a11yStr=positive x"), - Iteration("+1234", "expression=+1234", "a11yStr=positive 1,234"), - Iteration("+3.14", "expression=+3.14", "a11yStr=positive 3.14"), - Iteration("+z", "expression=+z", "a11yStr=positive zed") - ) + @Iteration("+2", "expression=+2", "a11yStr=positive 2") + @Iteration("+x", "expression=+x", "a11yStr=positive x") + @Iteration("+1234", "expression=+1234", "a11yStr=positive 1,234") + @Iteration("+3.14", "expression=+3.14", "a11yStr=positive 3.14") + @Iteration("+z", "expression=+z", "a11yStr=positive zed") fun testConvertToString_eng_positiveUnary_returnsPositiveOperandString() { // Allow positive unary operations to verify this case. val exp = parseAlgebraicExpression(expression, errorCheckingMode = REQUIRED_ONLY) @@ -377,18 +352,16 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("√2", "expression=√2", "a11yStr=square root of 2"), - Iteration("√x", "expression=√x", "a11yStr=square root of x"), - Iteration("√z", "expression=√z", "a11yStr=square root of zed"), - Iteration("√1234", "expression=√1234", "a11yStr=square root of 1,234"), - Iteration("√3.14", "expression=√3.14", "a11yStr=square root of 3.14"), - Iteration("√(2)", "expression=√(2)", "a11yStr=square root of 2"), - Iteration("√(x)", "expression=√(x)", "a11yStr=square root of x"), - Iteration("√(z)", "expression=√(z)", "a11yStr=square root of zed"), - Iteration("√(1234)", "expression=√(1234)", "a11yStr=square root of 1,234"), - Iteration("√(3.14)", "expression=√(3.14)", "a11yStr=square root of 3.14") - ) + @Iteration("√2", "expression=√2", "a11yStr=square root of 2") + @Iteration("√x", "expression=√x", "a11yStr=square root of x") + @Iteration("√z", "expression=√z", "a11yStr=square root of zed") + @Iteration("√1234", "expression=√1234", "a11yStr=square root of 1,234") + @Iteration("√3.14", "expression=√3.14", "a11yStr=square root of 3.14") + @Iteration("√(2)", "expression=√(2)", "a11yStr=square root of 2") + @Iteration("√(x)", "expression=√(x)", "a11yStr=square root of x") + @Iteration("√(z)", "expression=√(z)", "a11yStr=square root of zed") + @Iteration("√(1234)", "expression=√(1234)", "a11yStr=square root of 1,234") + @Iteration("√(3.14)", "expression=√(3.14)", "a11yStr=square root of 3.14") fun testConvertToString_eng_inlineSqrt_returnsSquareRootOfArgumentString() { // Allow for single-term parentheses for testing (even though these cases would normally result // in errors). @@ -398,13 +371,11 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("sqrt(2)", "expression=sqrt(2)", "a11yStr=square root of 2"), - Iteration("sqrt(x)", "expression=sqrt(x)", "a11yStr=square root of x"), - Iteration("sqrt(z)", "expression=sqrt(z)", "a11yStr=square root of zed"), - Iteration("sqrt(1234)", "expression=sqrt(1234)", "a11yStr=square root of 1,234"), - Iteration("sqrt(3.14)", "expression=sqrt(3.14)", "a11yStr=square root of 3.14") - ) + @Iteration("sqrt(2)", "expression=sqrt(2)", "a11yStr=square root of 2") + @Iteration("sqrt(x)", "expression=sqrt(x)", "a11yStr=square root of x") + @Iteration("sqrt(z)", "expression=sqrt(z)", "a11yStr=square root of zed") + @Iteration("sqrt(1234)", "expression=sqrt(1234)", "a11yStr=square root of 1,234") + @Iteration("sqrt(3.14)", "expression=sqrt(3.14)", "a11yStr=square root of 3.14") fun testConvertToString_eng_sqrt_returnsSquareRootOfArgumentString() { val exp = parseAlgebraicExpression(expression) @@ -412,22 +383,20 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("(2)", "expression=(2)", "a11yStr=2"), - Iteration("(x)", "expression=(x)", "a11yStr=x"), - Iteration("(z)", "expression=(z)", "a11yStr=zed"), - Iteration("(1234)", "expression=(1234)", "a11yStr=1,234"), - Iteration("(3.14)", "expression=(3.14)", "a11yStr=3.14"), - Iteration("((2))", "expression=((2))", "a11yStr=2"), - Iteration("((x))", "expression=((x))", "a11yStr=x"), - Iteration("((z))", "expression=((z))", "a11yStr=zed"), - Iteration("((1234))", "expression=((1234))", "a11yStr=1,234"), - Iteration("((3.14))", "expression=((3.14))", "a11yStr=3.14"), - Iteration("(√2)", "expression=(√2)", "a11yStr=square root of 2"), - Iteration("(√x)", "expression=(√x)", "a11yStr=square root of x"), - Iteration("(sqrt(2))", "expression=(sqrt(2))", "a11yStr=square root of 2"), - Iteration("(sqrt(x))", "expression=(sqrt(x))", "a11yStr=square root of x") - ) + @Iteration("(2)", "expression=(2)", "a11yStr=2") + @Iteration("(x)", "expression=(x)", "a11yStr=x") + @Iteration("(z)", "expression=(z)", "a11yStr=zed") + @Iteration("(1234)", "expression=(1234)", "a11yStr=1,234") + @Iteration("(3.14)", "expression=(3.14)", "a11yStr=3.14") + @Iteration("((2))", "expression=((2))", "a11yStr=2") + @Iteration("((x))", "expression=((x))", "a11yStr=x") + @Iteration("((z))", "expression=((z))", "a11yStr=zed") + @Iteration("((1234))", "expression=((1234))", "a11yStr=1,234") + @Iteration("((3.14))", "expression=((3.14))", "a11yStr=3.14") + @Iteration("(√2)", "expression=(√2)", "a11yStr=square root of 2") + @Iteration("(√x)", "expression=(√x)", "a11yStr=square root of x") + @Iteration("(sqrt(2))", "expression=(sqrt(2))", "a11yStr=square root of 2") + @Iteration("(sqrt(x))", "expression=(sqrt(x))", "a11yStr=square root of x") fun testConvertToString_eng_group_singleTermOrNestedSingleTerm_returnsDirectString() { // Allow for single-term parentheses for testing (even though these cases would normally result // in errors). @@ -439,41 +408,39 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("(1+2)", "expression=(1+2)", "a11yStr=open parenthesis 1 plus 2 close parenthesis"), - Iteration("(1+x)", "expression=(1+x)", "a11yStr=open parenthesis 1 plus x close parenthesis"), - Iteration("(1+z)", "expression=(1+z)", "a11yStr=open parenthesis 1 plus zed close parenthesis"), - Iteration( - "(1+1234)", "expression=(1+1234)", "a11yStr=open parenthesis 1 plus 1,234 close parenthesis" - ), - Iteration( - "(1+3.14)", "expression=(1+3.14)", "a11yStr=open parenthesis 1 plus 3.14 close parenthesis" - ), - Iteration("(1-2)", "expression=(1-2)", "a11yStr=open parenthesis 1 minus 2 close parenthesis"), - Iteration("(x-2)", "expression=(x-2)", "a11yStr=open parenthesis x minus 2 close parenthesis"), - Iteration("(1*2)", "expression=(1*2)", "a11yStr=open parenthesis 1 times 2 close parenthesis"), - Iteration("(x*2)", "expression=(x*2)", "a11yStr=open parenthesis x times 2 close parenthesis"), - Iteration( - "(1/2)", "expression=(1/2)", "a11yStr=open parenthesis 1 divided by 2 close parenthesis" - ), - Iteration( - "(x/2)", "expression=(x/2)", "a11yStr=open parenthesis x divided by 2 close parenthesis" - ), - Iteration( - "(1^2)", - "expression=(1^2)", - "a11yStr=open parenthesis 1 raised to the power of 2 close parenthesis" - ), - Iteration( - "(x^2)", - "expression=(x^2)", - "a11yStr=open parenthesis x raised to the power of 2 close parenthesis" - ), - Iteration("(-2)", "expression=(-2)", "a11yStr=open parenthesis negative 2 close parenthesis"), - Iteration("(-x)", "expression=(-x)", "a11yStr=open parenthesis negative x close parenthesis"), - Iteration("(+2)", "expression=(+2)", "a11yStr=open parenthesis positive 2 close parenthesis"), - Iteration("(+x)", "expression=(+x)", "a11yStr=open parenthesis positive x close parenthesis") + @Iteration("(1+2)", "expression=(1+2)", "a11yStr=open parenthesis 1 plus 2 close parenthesis") + @Iteration("(1+x)", "expression=(1+x)", "a11yStr=open parenthesis 1 plus x close parenthesis") + @Iteration("(1+z)", "expression=(1+z)", "a11yStr=open parenthesis 1 plus zed close parenthesis") + @Iteration( + "(1+1234)", "expression=(1+1234)", "a11yStr=open parenthesis 1 plus 1,234 close parenthesis" + ) + @Iteration( + "(1+3.14)", "expression=(1+3.14)", "a11yStr=open parenthesis 1 plus 3.14 close parenthesis" + ) + @Iteration("(1-2)", "expression=(1-2)", "a11yStr=open parenthesis 1 minus 2 close parenthesis") + @Iteration("(x-2)", "expression=(x-2)", "a11yStr=open parenthesis x minus 2 close parenthesis") + @Iteration("(1*2)", "expression=(1*2)", "a11yStr=open parenthesis 1 times 2 close parenthesis") + @Iteration("(x*2)", "expression=(x*2)", "a11yStr=open parenthesis x times 2 close parenthesis") + @Iteration( + "(1/2)", "expression=(1/2)", "a11yStr=open parenthesis 1 divided by 2 close parenthesis" + ) + @Iteration( + "(x/2)", "expression=(x/2)", "a11yStr=open parenthesis x divided by 2 close parenthesis" + ) + @Iteration( + "(1^2)", + "expression=(1^2)", + "a11yStr=open parenthesis 1 raised to the power of 2 close parenthesis" + ) + @Iteration( + "(x^2)", + "expression=(x^2)", + "a11yStr=open parenthesis x raised to the power of 2 close parenthesis" ) + @Iteration("(-2)", "expression=(-2)", "a11yStr=open parenthesis negative 2 close parenthesis") + @Iteration("(-x)", "expression=(-x)", "a11yStr=open parenthesis negative x close parenthesis") + @Iteration("(+2)", "expression=(+2)", "a11yStr=open parenthesis positive 2 close parenthesis") + @Iteration("(+x)", "expression=(+x)", "a11yStr=open parenthesis positive x close parenthesis") fun testConvertToString_eng_group_nestedOps_returnOpenParensOpCloseParensString() { // Allow for the outer expression to have redundant parentheses to test cases when groups are // announced (even though these exact cases would normally result in an error). @@ -483,85 +450,83 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("√-2", "expression=√-2", "a11yStr=start square root negative 2 end square root"), - Iteration("√-x", "expression=√-x", "a11yStr=start square root negative x end square root"), - Iteration("√+2", "expression=√+2", "a11yStr=start square root positive 2 end square root"), - Iteration("√+x", "expression=√+x", "a11yStr=start square root positive x end square root"), - // Note that these cases compose with the group cases since √ only "attached" to the immediate - // next terms rather than being able to encapsulate a whole operation (like sqrt()). - Iteration( - "√(1+2)", - "expression=√(1+2)", - "a11yStr=start square root open parenthesis 1 plus 2 close parenthesis end square root" - ), - Iteration( - "√(1+x)", - "expression=√(1+x)", - "a11yStr=start square root open parenthesis 1 plus x close parenthesis end square root" - ), - Iteration( - "√(1-2)", - "expression=√(1-2)", - "a11yStr=start square root open parenthesis 1 minus 2 close parenthesis end square root" - ), - Iteration( - "√(1-x)", - "expression=√(1-x)", - "a11yStr=start square root open parenthesis 1 minus x close parenthesis end square root" - ), - Iteration( - "√(1*2)", - "expression=√(1*2)", - "a11yStr=start square root open parenthesis 1 times 2 close parenthesis end square root" - ), - Iteration( - "√(1*x)", - "expression=√(1*x)", - "a11yStr=start square root open parenthesis 1 times x close parenthesis end square root" - ), - Iteration( - "√(1/2)", - "expression=√(1/2)", - "a11yStr=start square root open parenthesis 1 divided by 2 close parenthesis end square root" - ), - Iteration( - "√(1/x)", - "expression=√(1/x)", - "a11yStr=start square root open parenthesis 1 divided by x close parenthesis end square root" - ), - Iteration( - "√(1^2)", - "expression=√(1^2)", - "a11yStr=start square root open parenthesis 1 raised to the power of 2 close parenthesis" + - " end square root" - ), - Iteration( - "√(1^x)", - "expression=√(1^x)", - "a11yStr=start square root open parenthesis 1 raised to the power of x close parenthesis" + - " end square root" - ), - Iteration( - "√(-2)", - "expression=√(-2)", - "a11yStr=start square root open parenthesis negative 2 close parenthesis end square root" - ), - Iteration( - "√(-x)", - "expression=√(-x)", - "a11yStr=start square root open parenthesis negative x close parenthesis end square root" - ), - Iteration( - "√(+2)", - "expression=√(+2)", - "a11yStr=start square root open parenthesis positive 2 close parenthesis end square root" - ), - Iteration( - "√(+x)", - "expression=√(+x)", - "a11yStr=start square root open parenthesis positive x close parenthesis end square root" - ) + @Iteration("√-2", "expression=√-2", "a11yStr=start square root negative 2 end square root") + @Iteration("√-x", "expression=√-x", "a11yStr=start square root negative x end square root") + @Iteration("√+2", "expression=√+2", "a11yStr=start square root positive 2 end square root") + @Iteration("√+x", "expression=√+x", "a11yStr=start square root positive x end square root") + // Note that these cases compose with the group cases since √ only "attached" to the immediate + // next terms rather than being able to encapsulate a whole operation (like sqrt()). + @Iteration( + "√(1+2)", + "expression=√(1+2)", + "a11yStr=start square root open parenthesis 1 plus 2 close parenthesis end square root" + ) + @Iteration( + "√(1+x)", + "expression=√(1+x)", + "a11yStr=start square root open parenthesis 1 plus x close parenthesis end square root" + ) + @Iteration( + "√(1-2)", + "expression=√(1-2)", + "a11yStr=start square root open parenthesis 1 minus 2 close parenthesis end square root" + ) + @Iteration( + "√(1-x)", + "expression=√(1-x)", + "a11yStr=start square root open parenthesis 1 minus x close parenthesis end square root" + ) + @Iteration( + "√(1*2)", + "expression=√(1*2)", + "a11yStr=start square root open parenthesis 1 times 2 close parenthesis end square root" + ) + @Iteration( + "√(1*x)", + "expression=√(1*x)", + "a11yStr=start square root open parenthesis 1 times x close parenthesis end square root" + ) + @Iteration( + "√(1/2)", + "expression=√(1/2)", + "a11yStr=start square root open parenthesis 1 divided by 2 close parenthesis end square root" + ) + @Iteration( + "√(1/x)", + "expression=√(1/x)", + "a11yStr=start square root open parenthesis 1 divided by x close parenthesis end square root" + ) + @Iteration( + "√(1^2)", + "expression=√(1^2)", + "a11yStr=start square root open parenthesis 1 raised to the power of 2 close parenthesis" + + " end square root" + ) + @Iteration( + "√(1^x)", + "expression=√(1^x)", + "a11yStr=start square root open parenthesis 1 raised to the power of x close parenthesis" + + " end square root" + ) + @Iteration( + "√(-2)", + "expression=√(-2)", + "a11yStr=start square root open parenthesis negative 2 close parenthesis end square root" + ) + @Iteration( + "√(-x)", + "expression=√(-x)", + "a11yStr=start square root open parenthesis negative x close parenthesis end square root" + ) + @Iteration( + "√(+2)", + "expression=√(+2)", + "a11yStr=start square root open parenthesis positive 2 close parenthesis end square root" + ) + @Iteration( + "√(+x)", + "expression=√(+x)", + "a11yStr=start square root open parenthesis positive x close parenthesis end square root" ) fun testConvertToString_eng_inlineSqrt_nestedOp_returnsStartSquareRootConstructString() { // Allow for positive unary expressions. @@ -571,57 +536,55 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration( - "sqrt(1+2)", "expression=sqrt(1+2)", "a11yStr=start square root 1 plus 2 end square root" - ), - Iteration( - "sqrt(1+x)", "expression=sqrt(1+x)", "a11yStr=start square root 1 plus x end square root" - ), - Iteration( - "sqrt(1-2)", "expression=sqrt(1-2)", "a11yStr=start square root 1 minus 2 end square root" - ), - Iteration( - "sqrt(1-x)", "expression=sqrt(1-x)", "a11yStr=start square root 1 minus x end square root" - ), - Iteration( - "sqrt(1*2)", "expression=sqrt(1*2)", "a11yStr=start square root 1 times 2 end square root" - ), - Iteration( - "sqrt(1*x)", "expression=sqrt(1*x)", "a11yStr=start square root 1 times x end square root" - ), - Iteration( - "sqrt(1/2)", - "expression=sqrt(1/2)", - "a11yStr=start square root 1 divided by 2 end square root" - ), - Iteration( - "sqrt(1/x)", - "expression=sqrt(1/x)", - "a11yStr=start square root 1 divided by x end square root" - ), - Iteration( - "sqrt(1^2)", - "expression=sqrt(1^2)", - "a11yStr=start square root 1 raised to the power of 2 end square root" - ), - Iteration( - "sqrt(1^x)", - "expression=sqrt(1^x)", - "a11yStr=start square root 1 raised to the power of x end square root" - ), - Iteration( - "sqrt(-2)", "expression=sqrt(-2)", "a11yStr=start square root negative 2 end square root" - ), - Iteration( - "sqrt(-x)", "expression=sqrt(-x)", "a11yStr=start square root negative x end square root" - ), - Iteration( - "sqrt(+2)", "expression=sqrt(+2)", "a11yStr=start square root positive 2 end square root" - ), - Iteration( - "sqrt(+x)", "expression=sqrt(+x)", "a11yStr=start square root positive x end square root" - ) + @Iteration( + "sqrt(1+2)", "expression=sqrt(1+2)", "a11yStr=start square root 1 plus 2 end square root" + ) + @Iteration( + "sqrt(1+x)", "expression=sqrt(1+x)", "a11yStr=start square root 1 plus x end square root" + ) + @Iteration( + "sqrt(1-2)", "expression=sqrt(1-2)", "a11yStr=start square root 1 minus 2 end square root" + ) + @Iteration( + "sqrt(1-x)", "expression=sqrt(1-x)", "a11yStr=start square root 1 minus x end square root" + ) + @Iteration( + "sqrt(1*2)", "expression=sqrt(1*2)", "a11yStr=start square root 1 times 2 end square root" + ) + @Iteration( + "sqrt(1*x)", "expression=sqrt(1*x)", "a11yStr=start square root 1 times x end square root" + ) + @Iteration( + "sqrt(1/2)", + "expression=sqrt(1/2)", + "a11yStr=start square root 1 divided by 2 end square root" + ) + @Iteration( + "sqrt(1/x)", + "expression=sqrt(1/x)", + "a11yStr=start square root 1 divided by x end square root" + ) + @Iteration( + "sqrt(1^2)", + "expression=sqrt(1^2)", + "a11yStr=start square root 1 raised to the power of 2 end square root" + ) + @Iteration( + "sqrt(1^x)", + "expression=sqrt(1^x)", + "a11yStr=start square root 1 raised to the power of x end square root" + ) + @Iteration( + "sqrt(-2)", "expression=sqrt(-2)", "a11yStr=start square root negative 2 end square root" + ) + @Iteration( + "sqrt(-x)", "expression=sqrt(-x)", "a11yStr=start square root negative x end square root" + ) + @Iteration( + "sqrt(+2)", "expression=sqrt(+2)", "a11yStr=start square root positive 2 end square root" + ) + @Iteration( + "sqrt(+x)", "expression=sqrt(+x)", "a11yStr=start square root positive x end square root" ) fun testConvertToString_eng_sqrt_nestedOp_returnsStartSquareRootConstructString() { // Allow for positive unary expressions. @@ -631,15 +594,13 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - // Note that numeric exponentiations must be explicitly multiplied next to a constant. They - // otherwise result in a grammatical error that cannot be resolved. - Iteration("2x", "expression=2x", "a11yStr=2 x"), - Iteration("2z", "expression=2z", "a11yStr=2 zed"), - Iteration("2x^3", "expression=2x^3", "a11yStr=2 x raised to the power of 3"), - Iteration("2z^3", "expression=2z^3", "a11yStr=2 zed raised to the power of 3"), - Iteration("1234x^3.14", "expression=1234x^3.14", "a11yStr=1,234 x raised to the power of 3.14") - ) + // Note that numeric exponentiations must be explicitly multiplied next to a constant. They + // otherwise result in a grammatical error that cannot be resolved. + @Iteration("2x", "expression=2x", "a11yStr=2 x") + @Iteration("2z", "expression=2z", "a11yStr=2 zed") + @Iteration("2x^3", "expression=2x^3", "a11yStr=2 x raised to the power of 3") + @Iteration("2z^3", "expression=2z^3", "a11yStr=2 zed raised to the power of 3") + @Iteration("1234x^3.14", "expression=1234x^3.14", "a11yStr=1,234 x raised to the power of 3.14") fun testConvertToString_eng_implicitMult_leftConst_rightVarOrExp_returnsLeftRightString() { val exp = parseAlgebraicExpression(expression) @@ -649,18 +610,16 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("xz", "expression=xz", "a11yStr=x times zed"), - Iteration("2xy", "expression=2yx", "a11yStr=2 y times x"), - Iteration("2√x", "expression=2√x", "a11yStr=2 times square root of x"), - Iteration("2sqrt(x)", "expression=2sqrt(x)", "a11yStr=2 times square root of x"), - Iteration("2(3)", "expression=2(3)", "a11yStr=2 times 3"), - Iteration("2(x)", "expression=2(x)", "a11yStr=2 times x"), - Iteration( - "2(x^3)", - "expression=2(x^3)", - "a11yStr=2 times open parenthesis x raised to the power of 3 close parenthesis" - ) + @Iteration("xz", "expression=xz", "a11yStr=x times zed") + @Iteration("2xy", "expression=2yx", "a11yStr=2 y times x") + @Iteration("2√x", "expression=2√x", "a11yStr=2 times square root of x") + @Iteration("2sqrt(x)", "expression=2sqrt(x)", "a11yStr=2 times square root of x") + @Iteration("2(3)", "expression=2(3)", "a11yStr=2 times 3") + @Iteration("2(x)", "expression=2(x)", "a11yStr=2 times x") + @Iteration( + "2(x^3)", + "expression=2(x^3)", + "a11yStr=2 times open parenthesis x raised to the power of 3 close parenthesis" ) fun testConvertToString_eng_impMult_nonLeftConst_orRightIsNotVarOrExp_returnsLeftTimesRightStr() { // Allow for redundant single-term parentheses. @@ -682,22 +641,20 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("0/1", "expression=0/1", "a11yStr=0 over 1"), - Iteration("1/1", "expression=1/1", "a11yStr=1 over 1"), - Iteration("0/2", "expression=0/2", "a11yStr=0 over 2"), - Iteration("2/2", "expression=2/2", "a11yStr=2 over 2"), - Iteration("0/3", "expression=0/3", "a11yStr=0 over 3"), - Iteration("1/3", "expression=1/3", "a11yStr=1 over 3"), - Iteration("2/3", "expression=2/3", "a11yStr=2 over 3"), - Iteration("3/3", "expression=3/3", "a11yStr=3 over 3"), - Iteration("4/3", "expression=4/3", "a11yStr=4 over 3"), - Iteration("5/3", "expression=5/3", "a11yStr=5 over 3"), - Iteration("6/3", "expression=6/3", "a11yStr=6 over 3"), - Iteration("5/9", "expression=5/9", "a11yStr=5 over 9"), - Iteration("19/3", "expression=19/3", "a11yStr=19 over 3"), - Iteration("2/17", "expression=2/17", "a11yStr=2 over 17") - ) + @Iteration("0/1", "expression=0/1", "a11yStr=0 over 1") + @Iteration("1/1", "expression=1/1", "a11yStr=1 over 1") + @Iteration("0/2", "expression=0/2", "a11yStr=0 over 2") + @Iteration("2/2", "expression=2/2", "a11yStr=2 over 2") + @Iteration("0/3", "expression=0/3", "a11yStr=0 over 3") + @Iteration("1/3", "expression=1/3", "a11yStr=1 over 3") + @Iteration("2/3", "expression=2/3", "a11yStr=2 over 3") + @Iteration("3/3", "expression=3/3", "a11yStr=3 over 3") + @Iteration("4/3", "expression=4/3", "a11yStr=4 over 3") + @Iteration("5/3", "expression=5/3", "a11yStr=5 over 3") + @Iteration("6/3", "expression=6/3", "a11yStr=6 over 3") + @Iteration("5/9", "expression=5/9", "a11yStr=5 over 9") + @Iteration("19/3", "expression=19/3", "a11yStr=19 over 3") + @Iteration("2/17", "expression=2/17", "a11yStr=2 over 17") fun testConvertToString_eng_divisionAsFractions_smallIntegerFracs_returnsNumOverDenomString() { val exp = parseAlgebraicExpression(expression) @@ -705,11 +662,9 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("1/1234", "expression=1/1234", "a11yStr=1 over 1,234"), - Iteration("1234/1", "expression=1234/1", "a11yStr=1,234 over 1"), - Iteration("1234/987654", "expression=1234/987654", "a11yStr=1,234 over 987,654") - ) + @Iteration("1/1234", "expression=1/1234", "a11yStr=1 over 1,234") + @Iteration("1234/1", "expression=1234/1", "a11yStr=1,234 over 1") + @Iteration("1234/987654", "expression=1234/987654", "a11yStr=1,234 over 987,654") fun testConvertToString_eng_divisionAsFractions_largeIntegerFracs_returnsNumOverDenomString() { val exp = parseAlgebraicExpression(expression) @@ -718,13 +673,11 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("1/x", "expression=1/x", "a11yStr=1 over x"), - Iteration("1/z", "expression=1/z", "a11yStr=1 over zed"), - Iteration("x/2", "expression=x/2", "a11yStr=x over 2"), - Iteration("z/3", "expression=z/3", "a11yStr=zed over 3"), - Iteration("x/z", "expression=x/z", "a11yStr=x over zed") - ) + @Iteration("1/x", "expression=1/x", "a11yStr=1 over x") + @Iteration("1/z", "expression=1/z", "a11yStr=1 over zed") + @Iteration("x/2", "expression=x/2", "a11yStr=x over 2") + @Iteration("z/3", "expression=z/3", "a11yStr=zed over 3") + @Iteration("x/z", "expression=x/z", "a11yStr=x over zed") fun testConvertToString_eng_divisionAsFractions_fracsWithVariables_returnsNumOverDenomString() { val exp = parseAlgebraicExpression(expression) @@ -733,48 +686,46 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration( - "x/√2", - "expression=x/√2", - "a11yStr=the fraction with numerator x and denominator square root of 2" - ), - Iteration( - "x/-2", - "expression=x/-2", - "a11yStr=the fraction with numerator x and denominator negative 2" - ), - Iteration( - "2/(1+2)", - "expression=2/(1+2)", - "a11yStr=the fraction with numerator 2 and denominator open parenthesis 1 plus 2 close" + - " parenthesis" - ), - // Nested fractions still cause the outer fraction to be read out the long way. - Iteration( - "2/(1/2)", - "expression=2/(1/2)", - "a11yStr=the fraction with numerator 2 and denominator open parenthesis one half close" + - " parenthesis" - ), - Iteration( - "2/(1/3)", - "expression=2/(1/3)", - "a11yStr=the fraction with numerator 2 and denominator open parenthesis 1 over 3 close" + - " parenthesis" - ), - Iteration( - "x/sqrt(y/3)", - "expression=x/sqrt(y/3)", - "a11yStr=the fraction with numerator x and denominator start square root y over 3 end" + - " square root" - ), - Iteration( - "3.14/x", "expression=3.14/x", "a11yStr=the fraction with numerator 3.14 and denominator x" - ), - Iteration( - "x/3.14", "expression=x/3.14", "a11yStr=the fraction with numerator x and denominator 3.14" - ) + @Iteration( + "x/√2", + "expression=x/√2", + "a11yStr=the fraction with numerator x and denominator square root of 2" + ) + @Iteration( + "x/-2", + "expression=x/-2", + "a11yStr=the fraction with numerator x and denominator negative 2" + ) + @Iteration( + "2/(1+2)", + "expression=2/(1+2)", + "a11yStr=the fraction with numerator 2 and denominator open parenthesis 1 plus 2 close" + + " parenthesis" + ) + // Nested fractions still cause the outer fraction to be read out the long way. + @Iteration( + "2/(1/2)", + "expression=2/(1/2)", + "a11yStr=the fraction with numerator 2 and denominator open parenthesis one half close" + + " parenthesis" + ) + @Iteration( + "2/(1/3)", + "expression=2/(1/3)", + "a11yStr=the fraction with numerator 2 and denominator open parenthesis 1 over 3 close" + + " parenthesis" + ) + @Iteration( + "x/sqrt(y/3)", + "expression=x/sqrt(y/3)", + "a11yStr=the fraction with numerator x and denominator start square root y over 3 end" + + " square root" + ) + @Iteration( + "3.14/x", "expression=3.14/x", "a11yStr=the fraction with numerator 3.14 and denominator x" + ) + @Iteration( + "x/3.14", "expression=x/3.14", "a11yStr=the fraction with numerator x and denominator 3.14" ) fun testConvertToString_eng_divisionAsFractions_fracWithComplexParts_returnsFracConstructStr() { val exp = parseAlgebraicExpression(expression) @@ -784,14 +735,12 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("1=2", "expression=1=2", "a11yStr=1 equals 2"), - Iteration("x=1", "expression=x=1", "a11yStr=x equals 1"), - Iteration("z=1", "expression=z=1", "a11yStr=zed equals 1"), - Iteration("2=x", "expression=2=x", "a11yStr=2 equals x"), - Iteration("2=z", "expression=2=z", "a11yStr=2 equals zed"), - Iteration("x=z", "expression=x=z", "a11yStr=x equals zed") - ) + @Iteration("1=2", "expression=1=2", "a11yStr=1 equals 2") + @Iteration("x=1", "expression=x=1", "a11yStr=x equals 1") + @Iteration("z=1", "expression=z=1", "a11yStr=zed equals 1") + @Iteration("2=x", "expression=2=x", "a11yStr=2 equals x") + @Iteration("2=z", "expression=2=z", "a11yStr=2 equals zed") + @Iteration("x=z", "expression=x=z", "a11yStr=x equals zed") fun testConvertToString_eng_simpleEquation_returnsLeftEqualsRightString() { val eq = parseAlgebraicEquation(expression) @@ -799,19 +748,17 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("xyz", "expression=xyz", "a11yStr=x times y times zed"), - Iteration("1+x+x^2", "expression=1+x+x^2", "a11yStr=1 plus x plus x raised to the power of 2"), - Iteration( - "-3x^2+23x-14", - "expression=-3x^2+23x-14", - "a11yStr=negative 3 times x raised to the power of 2 plus 23 x minus 14" - ), - Iteration( - "y^2+xy+x^2", - "expression=y^2+xy+x^2", - "a11yStr=y raised to the power of 2 plus x times y plus x raised to the power of 2" - ) + @Iteration("xyz", "expression=xyz", "a11yStr=x times y times zed") + @Iteration("1+x+x^2", "expression=1+x+x^2", "a11yStr=1 plus x plus x raised to the power of 2") + @Iteration( + "-3x^2+23x-14", + "expression=-3x^2+23x-14", + "a11yStr=negative 3 times x raised to the power of 2 plus 23 x minus 14" + ) + @Iteration( + "y^2+xy+x^2", + "expression=y^2+xy+x^2", + "a11yStr=y raised to the power of 2 plus x times y plus x raised to the power of 2" ) fun testConvertToString_eng_polynomialExpressions_returnsCorrectlyBuiltString() { val exp = parseAlgebraicExpression(expression) @@ -821,25 +768,23 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration("z=xyz", "expression=z=xyz", "a11yStr=zed equals x times y times zed"), - Iteration( - "y=1+x+x^2", - "expression=y=1+x+x^2", - "a11yStr=y equals 1 plus x plus x raised to the power of 2" - ), - Iteration( - "-3x^2+23x-14=7y^3", - "expression=-3x^2+23x-14=7y^3", - "a11yStr=negative 3 times x raised to the power of 2 plus 23 x minus 14 equals 7 y raised" + - " to the power of 3" - ), - Iteration( - "sqrt(z)=y^2+xy+x^2", - "expression=sqrt(z)=y^2+xy+x^2", - "a11yStr=square root of zed equals y raised to the power of 2 plus x times y plus x raised" + - " to the power of 2" - ) + @Iteration("z=xyz", "expression=z=xyz", "a11yStr=zed equals x times y times zed") + @Iteration( + "y=1+x+x^2", + "expression=y=1+x+x^2", + "a11yStr=y equals 1 plus x plus x raised to the power of 2" + ) + @Iteration( + "-3x^2+23x-14=7y^3", + "expression=-3x^2+23x-14=7y^3", + "a11yStr=negative 3 times x raised to the power of 2 plus 23 x minus 14 equals 7 y raised" + + " to the power of 3" + ) + @Iteration( + "sqrt(z)=y^2+xy+x^2", + "expression=sqrt(z)=y^2+xy+x^2", + "a11yStr=square root of zed equals y raised to the power of 2 plus x times y plus x raised" + + " to the power of 2" ) fun testConvertToString_eng_polynomialEquations_returnsCorrectlyBuiltString() { val eq = parseAlgebraicEquation(expression) @@ -849,50 +794,48 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration( - "(x^2+2x+1)/(x+1)", - "expression= ( x^2 + 2x + 1 ) /( x + 1)", - "a11yStr=open parenthesis x raised to the power of 2 plus 2 x plus 1 close parenthesis" + - " divided by open parenthesis x plus 1 close parenthesis" - ), - Iteration( - "(1/2)x", - "expression=(1/2) x", - "a11yStr=open parenthesis 1 divided by 2 close parenthesis times x" - ), - Iteration( - "(-27x^3)^(1/3)", - "expression=(\t-27x\n^3\r)^(1 / 3) ", - "a11yStr=open parenthesis negative 27 times x raised to the power of 3 close parenthesis" + - " raised to the power of open parenthesis 1 divided by 3 close parenthesis" - ), - Iteration( - "(4x^2)^(-1/2)", - "expression=( 4x ^ 2) ^ ( - 1 / 2 ) ", - "a11yStr=open parenthesis 4 x raised to the power of 2 close parenthesis raised to the" + - " power of open parenthesis negative 1 divided by 2 close parenthesis" - ), - Iteration( - "sqrt(sqrt(sqrt(x)+1))", - "expression=sqrt( sqrt( sqrt( x ) + 1 ) )", - "a11yStr=square root of start square root square root of x plus 1 end square root" - ), - Iteration( - "x-(1+(y-(2+z)))", - "expression= x - ( 1 + ( y - ( 2 + z )))", - "a11yStr=x minus open parenthesis 1 plus open parenthesis y minus open parenthesis 2 plus" + - " zed close parenthesis close parenthesis close parenthesis" - ), - Iteration( - "1/(2/(y+3/z))", - "expression=1 / ( 2 / ( y + 3/z ) )", - "a11yStr=1 divided by open parenthesis 2 divided by open parenthesis y plus 3 divided by" + - " zed close parenthesis close parenthesis" - ), - Iteration( - "x/y/z/2", "expression= x/ y/ z/ 2", "a11yStr=x divided by y divided by zed divided by 2" - ) + @Iteration( + "(x^2+2x+1)/(x+1)", + "expression= ( x^2 + 2x + 1 ) /( x + 1)", + "a11yStr=open parenthesis x raised to the power of 2 plus 2 x plus 1 close parenthesis" + + " divided by open parenthesis x plus 1 close parenthesis" + ) + @Iteration( + "(1/2)x", + "expression=(1/2) x", + "a11yStr=open parenthesis 1 divided by 2 close parenthesis times x" + ) + @Iteration( + "(-27x^3)^(1/3)", + "expression=(\t-27x\n^3\r)^(1 / 3) ", + "a11yStr=open parenthesis negative 27 times x raised to the power of 3 close parenthesis" + + " raised to the power of open parenthesis 1 divided by 3 close parenthesis" + ) + @Iteration( + "(4x^2)^(-1/2)", + "expression=( 4x ^ 2) ^ ( - 1 / 2 ) ", + "a11yStr=open parenthesis 4 x raised to the power of 2 close parenthesis raised to the" + + " power of open parenthesis negative 1 divided by 2 close parenthesis" + ) + @Iteration( + "sqrt(sqrt(sqrt(x)+1))", + "expression=sqrt( sqrt( sqrt( x ) + 1 ) )", + "a11yStr=square root of start square root square root of x plus 1 end square root" + ) + @Iteration( + "x-(1+(y-(2+z)))", + "expression= x - ( 1 + ( y - ( 2 + z )))", + "a11yStr=x minus open parenthesis 1 plus open parenthesis y minus open parenthesis 2 plus" + + " zed close parenthesis close parenthesis close parenthesis" + ) + @Iteration( + "1/(2/(y+3/z))", + "expression=1 / ( 2 / ( y + 3/z ) )", + "a11yStr=1 divided by open parenthesis 2 divided by open parenthesis y plus 3 divided by" + + " zed close parenthesis close parenthesis" + ) + @Iteration( + "x/y/z/2", "expression= x/ y/ z/ 2", "a11yStr=x divided by y divided by zed divided by 2" ) fun testConvertToString_eng_complexNestedExpression_returnsCorrectlyBuiltString() { val exp = parseAlgebraicExpression(expression) @@ -903,53 +846,51 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration( - "(x^2+2x+1)/(x+1)", - "expression= ( x^2 + 2x + 1 ) /( x + 1)", - "a11yStr=the fraction with numerator open parenthesis x raised to the power of 2 plus 2 x" + - " plus 1 close parenthesis and denominator open parenthesis x plus 1 close parenthesis" - ), - Iteration( - "(1/2)x", "expression=(1/2) x", "a11yStr=open parenthesis one half close parenthesis times x" - ), - Iteration( - "(-27x^3)^(1/3)", - "expression=(\t-27x\n^3\r)^(1 / 3) ", - "a11yStr=open parenthesis negative 27 times x raised to the power of 3 close parenthesis" + - " raised to the power of open parenthesis 1 over 3 close parenthesis" - ), - Iteration( - "(4x^2)^(-1/2)", - "expression=( 4x ^ 2) ^ ( - 1 / 2 ) ", - "a11yStr=open parenthesis 4 x raised to the power of 2 close parenthesis raised to the" + - " power of open parenthesis the fraction with numerator negative 1 and denominator 2" + - " close parenthesis" - ), - Iteration( - "sqrt(sqrt(sqrt(x)+1))", - "expression=sqrt( sqrt( sqrt( x ) + 1 ) )", - "a11yStr=square root of start square root square root of x plus 1 end square root" - ), - Iteration( - "x-(1+(y-(2+z)))", - "expression= x - ( 1 + ( y - ( 2 + z )))", - "a11yStr=x minus open parenthesis 1 plus open parenthesis y minus open parenthesis 2 plus" + - " zed close parenthesis close parenthesis close parenthesis" - ), - Iteration( - "1/(2/(y+3/z))", - "expression=1 / ( 2 / ( y + 3/z ) )", - "a11yStr=the fraction with numerator 1 and denominator open parenthesis the fraction with" + - " numerator 2 and denominator open parenthesis y plus 3 over zed close parenthesis" + - " close parenthesis" - ), - Iteration( - "x/y/z/2", - "expression= x/ y/ z/ 2", - "a11yStr=the fraction with numerator the fraction with numerator x over y and denominator" + - " zed and denominator 2" - ) + @Iteration( + "(x^2+2x+1)/(x+1)", + "expression= ( x^2 + 2x + 1 ) /( x + 1)", + "a11yStr=the fraction with numerator open parenthesis x raised to the power of 2 plus 2 x" + + " plus 1 close parenthesis and denominator open parenthesis x plus 1 close parenthesis" + ) + @Iteration( + "(1/2)x", "expression=(1/2) x", "a11yStr=open parenthesis one half close parenthesis times x" + ) + @Iteration( + "(-27x^3)^(1/3)", + "expression=(\t-27x\n^3\r)^(1 / 3) ", + "a11yStr=open parenthesis negative 27 times x raised to the power of 3 close parenthesis" + + " raised to the power of open parenthesis 1 over 3 close parenthesis" + ) + @Iteration( + "(4x^2)^(-1/2)", + "expression=( 4x ^ 2) ^ ( - 1 / 2 ) ", + "a11yStr=open parenthesis 4 x raised to the power of 2 close parenthesis raised to the" + + " power of open parenthesis the fraction with numerator negative 1 and denominator 2" + + " close parenthesis" + ) + @Iteration( + "sqrt(sqrt(sqrt(x)+1))", + "expression=sqrt( sqrt( sqrt( x ) + 1 ) )", + "a11yStr=square root of start square root square root of x plus 1 end square root" + ) + @Iteration( + "x-(1+(y-(2+z)))", + "expression= x - ( 1 + ( y - ( 2 + z )))", + "a11yStr=x minus open parenthesis 1 plus open parenthesis y minus open parenthesis 2 plus" + + " zed close parenthesis close parenthesis close parenthesis" + ) + @Iteration( + "1/(2/(y+3/z))", + "expression=1 / ( 2 / ( y + 3/z ) )", + "a11yStr=the fraction with numerator 1 and denominator open parenthesis the fraction with" + + " numerator 2 and denominator open parenthesis y plus 3 over zed close parenthesis" + + " close parenthesis" + ) + @Iteration( + "x/y/z/2", + "expression= x/ y/ z/ 2", + "a11yStr=the fraction with numerator the fraction with numerator x over y and denominator" + + " zed and denominator 2" ) fun testConvertToString_eng_complexNestedExpression_divAsFracs_returnsCorrectlyBuiltString() { val exp = parseAlgebraicExpression(expression) @@ -960,54 +901,52 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration( - "y=(x^2+2x+1)/(x+1)", - "expression= y = ( x^2 + 2x + 1 ) /( x + 1)", - "a11yStr=y equals open parenthesis x raised to the power of 2 plus 2 x plus 1 close" + - " parenthesis divided by open parenthesis x plus 1 close parenthesis" - ), - Iteration( - "(1/2)x=sqrt(x)", - "expression=(1/2) x =sqrt (x)", - "a11yStr=open parenthesis 1 divided by 2 close parenthesis times x equals square root of x" - ), - Iteration( - "-3x=(-27x^3)^(1/3)", - "expression=\n-\n3\nx\n=\n(\t-27x\n^3\r)^(1 / 3) ", - "a11yStr=negative 3 times x equals open parenthesis negative 27 times x raised to the power" + - " of 3 close parenthesis raised to the power of open parenthesis 1 divided by 3 close" + - " parenthesis" - ), - Iteration( - "(4x^2)^(-1/2)=1+x", - "expression=( 4x ^ 2) ^ ( - 1 / 2 ) =1 + x ", - "a11yStr=open parenthesis 4 x raised to the power of 2 close parenthesis raised to the" + - " power of open parenthesis negative 1 divided by 2 close parenthesis equals 1 plus x" - ), - Iteration( - "sqrt(sqrt(sqrt(x)+1))=1/2", - "expression=sqrt( sqrt( sqrt( x ) + 1 ) ) = 1 / 2", - "a11yStr=square root of start square root square root of x plus 1 end square root equals 1" + - " divided by 2" - ), - Iteration( - "xy+x+y=x-(1+(y-(2+z)))", - "expression=xy+x+y=x - ( 1 + ( y - ( 2 + z )))", - "a11yStr=x times y plus x plus y equals x minus open parenthesis 1 plus open parenthesis y" + - " minus open parenthesis 2 plus zed close parenthesis close parenthesis close parenthesis" - ), - Iteration( - "x=1/(2/(y+3/z))", - "expression= x = 1 / ( 2 / ( y + 3/z ) )", - "a11yStr=x equals 1 divided by open parenthesis 2 divided by open parenthesis y plus 3" + - " divided by zed close parenthesis close parenthesis" - ), - Iteration( - "x/y/z/2=z", - "expression= x/ y/ z/ 2=z", - "a11yStr=x divided by y divided by zed divided by 2 equals zed" - ) + @Iteration( + "y=(x^2+2x+1)/(x+1)", + "expression= y = ( x^2 + 2x + 1 ) /( x + 1)", + "a11yStr=y equals open parenthesis x raised to the power of 2 plus 2 x plus 1 close" + + " parenthesis divided by open parenthesis x plus 1 close parenthesis" + ) + @Iteration( + "(1/2)x=sqrt(x)", + "expression=(1/2) x =sqrt (x)", + "a11yStr=open parenthesis 1 divided by 2 close parenthesis times x equals square root of x" + ) + @Iteration( + "-3x=(-27x^3)^(1/3)", + "expression=\n-\n3\nx\n=\n(\t-27x\n^3\r)^(1 / 3) ", + "a11yStr=negative 3 times x equals open parenthesis negative 27 times x raised to the power" + + " of 3 close parenthesis raised to the power of open parenthesis 1 divided by 3 close" + + " parenthesis" + ) + @Iteration( + "(4x^2)^(-1/2)=1+x", + "expression=( 4x ^ 2) ^ ( - 1 / 2 ) =1 + x ", + "a11yStr=open parenthesis 4 x raised to the power of 2 close parenthesis raised to the" + + " power of open parenthesis negative 1 divided by 2 close parenthesis equals 1 plus x" + ) + @Iteration( + "sqrt(sqrt(sqrt(x)+1))=1/2", + "expression=sqrt( sqrt( sqrt( x ) + 1 ) ) = 1 / 2", + "a11yStr=square root of start square root square root of x plus 1 end square root equals 1" + + " divided by 2" + ) + @Iteration( + "xy+x+y=x-(1+(y-(2+z)))", + "expression=xy+x+y=x - ( 1 + ( y - ( 2 + z )))", + "a11yStr=x times y plus x plus y equals x minus open parenthesis 1 plus open parenthesis y" + + " minus open parenthesis 2 plus zed close parenthesis close parenthesis close parenthesis" + ) + @Iteration( + "x=1/(2/(y+3/z))", + "expression= x = 1 / ( 2 / ( y + 3/z ) )", + "a11yStr=x equals 1 divided by open parenthesis 2 divided by open parenthesis y plus 3" + + " divided by zed close parenthesis close parenthesis" + ) + @Iteration( + "x/y/z/2=z", + "expression= x/ y/ z/ 2=z", + "a11yStr=x divided by y divided by zed divided by 2 equals zed" ) fun testConvertToString_eng_complexNestedEquations_returnsCorrectlyBuiltString() { val eq = parseAlgebraicEquation(expression) @@ -1018,57 +957,55 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration( - "y=(x^2+2x+1)/(x+1)", - "expression= y = ( x^2 + 2x + 1 ) /( x + 1)", - "a11yStr=y equals the fraction with numerator open parenthesis x raised to the power of 2" + - " plus 2 x plus 1 close parenthesis and denominator open parenthesis x plus 1 close" + - " parenthesis" - ), - Iteration( - "(1/2)x=sqrt(x)", - "expression=(1/2) x =sqrt (x)", - "a11yStr=open parenthesis one half close parenthesis times x equals square root of x" - ), - Iteration( - "-3x=(-27x^3)^(1/3)", - "expression=\n-\n3\nx\n=\n(\t-27x\n^3\r)^(1 / 3) ", - "a11yStr=negative 3 times x equals open parenthesis negative 27 times x raised to the power" + - " of 3 close parenthesis raised to the power of open parenthesis 1 over 3 close parenthesis" - ), - Iteration( - "(4x^2)^(-1/2)=1+x", - "expression=( 4x ^ 2) ^ ( - 1 / 2 ) =1 + x ", - "a11yStr=open parenthesis 4 x raised to the power of 2 close parenthesis raised to the" + - " power of open parenthesis the fraction with numerator negative 1 and denominator 2" + - " close parenthesis equals 1 plus x" - ), - Iteration( - "sqrt(sqrt(sqrt(x)+1))=1/2", - "expression=sqrt( sqrt( sqrt( x ) + 1 ) ) = 1 / 2", - "a11yStr=square root of start square root square root of x plus 1 end square root equals" + - " one half" - ), - Iteration( - "xy+x+y=x-(1+(y-(2+z)))", - "expression=xy+x+y=x - ( 1 + ( y - ( 2 + z )))", - "a11yStr=x times y plus x plus y equals x minus open parenthesis 1 plus open parenthesis y" + - " minus open parenthesis 2 plus zed close parenthesis close parenthesis close parenthesis" - ), - Iteration( - "x=1/(2/(y+3/z))", - "expression= x = 1 / ( 2 / ( y + 3/z ) )", - "a11yStr=x equals the fraction with numerator 1 and denominator open parenthesis the" + - " fraction with numerator 2 and denominator open parenthesis y plus 3 over zed close" + - " parenthesis close parenthesis" - ), - Iteration( - "x/y/z/2=z", - "expression= x/ y/ z/ 2=z", - "a11yStr=the fraction with numerator the fraction with numerator x over y and denominator" + - " zed and denominator 2 equals zed" - ) + @Iteration( + "y=(x^2+2x+1)/(x+1)", + "expression= y = ( x^2 + 2x + 1 ) /( x + 1)", + "a11yStr=y equals the fraction with numerator open parenthesis x raised to the power of 2" + + " plus 2 x plus 1 close parenthesis and denominator open parenthesis x plus 1 close" + + " parenthesis" + ) + @Iteration( + "(1/2)x=sqrt(x)", + "expression=(1/2) x =sqrt (x)", + "a11yStr=open parenthesis one half close parenthesis times x equals square root of x" + ) + @Iteration( + "-3x=(-27x^3)^(1/3)", + "expression=\n-\n3\nx\n=\n(\t-27x\n^3\r)^(1 / 3) ", + "a11yStr=negative 3 times x equals open parenthesis negative 27 times x raised to the power" + + " of 3 close parenthesis raised to the power of open parenthesis 1 over 3 close parenthesis" + ) + @Iteration( + "(4x^2)^(-1/2)=1+x", + "expression=( 4x ^ 2) ^ ( - 1 / 2 ) =1 + x ", + "a11yStr=open parenthesis 4 x raised to the power of 2 close parenthesis raised to the" + + " power of open parenthesis the fraction with numerator negative 1 and denominator 2" + + " close parenthesis equals 1 plus x" + ) + @Iteration( + "sqrt(sqrt(sqrt(x)+1))=1/2", + "expression=sqrt( sqrt( sqrt( x ) + 1 ) ) = 1 / 2", + "a11yStr=square root of start square root square root of x plus 1 end square root equals" + + " one half" + ) + @Iteration( + "xy+x+y=x-(1+(y-(2+z)))", + "expression=xy+x+y=x - ( 1 + ( y - ( 2 + z )))", + "a11yStr=x times y plus x plus y equals x minus open parenthesis 1 plus open parenthesis y" + + " minus open parenthesis 2 plus zed close parenthesis close parenthesis close parenthesis" + ) + @Iteration( + "x=1/(2/(y+3/z))", + "expression= x = 1 / ( 2 / ( y + 3/z ) )", + "a11yStr=x equals the fraction with numerator 1 and denominator open parenthesis the" + + " fraction with numerator 2 and denominator open parenthesis y plus 3 over zed close" + + " parenthesis close parenthesis" + ) + @Iteration( + "x/y/z/2=z", + "expression= x/ y/ z/ 2=z", + "a11yStr=the fraction with numerator the fraction with numerator x over y and denominator" + + " zed and denominator 2 equals zed" ) fun testConvertToString_eng_complexNestedEquations_divAsFracs_returnsCorrectlyBuiltString() { val eq = parseAlgebraicEquation(expression) @@ -1081,43 +1018,41 @@ class MathExpressionAccessibilityUtilTest { // This & the next test are implementing cases defined in the doc: // https://docs.google.com/document/d/1P-dldXQ08O-02ZRG978paiWOSz0dsvcKpDgiV_rKH_Y/edit#. @Test - @RunParameterized( - Iteration( - "(x + 6)/(x - 4)", - "expression=(x + 6)/(x - 4)", - "a11yStr=the fraction with numerator open parenthesis x plus 6 close parenthesis and" + - " denominator open parenthesis x minus 4 close parenthesis" - ), - Iteration( - "4*(x)^(2)+20x", - "expression=4*(x)^(2)+20x", - "a11yStr=4 times x raised to the power of 2 plus 20 x" - ), - Iteration("3+x-5", "expression=3+x-5", "a11yStr=3 plus x minus 5"), - Iteration("Z+A-Z", "expression=Z+A-Z", "a11yStr=Zed plus A minus Zed"), - Iteration("6C - 5A -1", "expression=6C - 5A -1", "a11yStr=6 C minus 5 A minus 1"), - Iteration("5*Z-w", "expression=5*Z-w", "a11yStr=5 times Zed minus w"), - Iteration("L*S-3S+L", "expression=L*S-3S+L", "a11yStr=L times S minus 3 S plus L"), - Iteration( - "2*(2+6+3+4)", - "expression=2*(2+6+3+4)", - "a11yStr=2 times open parenthesis 2 plus 6 plus 3 plus 4 close parenthesis" - ), - Iteration("sqrt(64)", "expression=sqrt(64)", "a11yStr=square root of 64"), - Iteration( - "√(a+b)", - "expression=√(a+b)", - "a11yStr=start square root open parenthesis a plus b close parenthesis end square root" - ), - Iteration( - "3 * 10^-5", "expression=3 * 10^-5", "a11yStr=3 times 10 raised to the power of negative 5" - ), - Iteration( - "((x+2y) + 5*(a - 2b) + z)", - "expression=((x+2y) + 5*(a - 2b) + z)", - "a11yStr=open parenthesis open parenthesis x plus 2 y close parenthesis plus 5 times open" + - " parenthesis a minus 2 b close parenthesis plus zed close parenthesis" - ) + @Iteration( + "(x + 6)/(x - 4)", + "expression=(x + 6)/(x - 4)", + "a11yStr=the fraction with numerator open parenthesis x plus 6 close parenthesis and" + + " denominator open parenthesis x minus 4 close parenthesis" + ) + @Iteration( + "4*(x)^(2)+20x", + "expression=4*(x)^(2)+20x", + "a11yStr=4 times x raised to the power of 2 plus 20 x" + ) + @Iteration("3+x-5", "expression=3+x-5", "a11yStr=3 plus x minus 5") + @Iteration("Z+A-Z", "expression=Z+A-Z", "a11yStr=Zed plus A minus Zed") + @Iteration("6C - 5A -1", "expression=6C - 5A -1", "a11yStr=6 C minus 5 A minus 1") + @Iteration("5*Z-w", "expression=5*Z-w", "a11yStr=5 times Zed minus w") + @Iteration("L*S-3S+L", "expression=L*S-3S+L", "a11yStr=L times S minus 3 S plus L") + @Iteration( + "2*(2+6+3+4)", + "expression=2*(2+6+3+4)", + "a11yStr=2 times open parenthesis 2 plus 6 plus 3 plus 4 close parenthesis" + ) + @Iteration("sqrt(64)", "expression=sqrt(64)", "a11yStr=square root of 64") + @Iteration( + "√(a+b)", + "expression=√(a+b)", + "a11yStr=start square root open parenthesis a plus b close parenthesis end square root" + ) + @Iteration( + "3 * 10^-5", "expression=3 * 10^-5", "a11yStr=3 times 10 raised to the power of negative 5" + ) + @Iteration( + "((x+2y) + 5*(a - 2b) + z)", + "expression=((x+2y) + 5*(a - 2b) + z)", + "a11yStr=open parenthesis open parenthesis x plus 2 y close parenthesis plus 5 times open" + + " parenthesis a minus 2 b close parenthesis plus zed close parenthesis" ) fun testConvertToString_eng_assortedExpressionsFromPrd_returnsCorrectlyComputedString() { // Some of the expressions include cases that would normally result in errors. @@ -1127,12 +1062,10 @@ class MathExpressionAccessibilityUtilTest { } @Test - @RunParameterized( - Iteration( - "3x^2 + 4y = 62", - "expression=3x^2 + 4y = 62", - "a11yStr=3 x raised to the power of 2 plus 4 y equals 62" - ) + @Iteration( + "3x^2 + 4y = 62", + "expression=3x^2 + 4y = 62", + "a11yStr=3 x raised to the power of 2 plus 4 y equals 62" ) fun testConvertToString_eng_assortedEquationsFromPrd_returnsCorrectlyComputedString() { val eq = parseAlgebraicEquation(expression) diff --git a/build.gradle b/build.gradle index e0b2d5f2b98..97172637258 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.4.20' + ext.kotlin_version = '1.6.10' ext.fragment_version = '1.2.0-rc01' repositories { google() diff --git a/config/kitkat_main_dex_class_list.txt b/config/kitkat_main_dex_class_list.txt index fd7f268faeb..a399ae49c61 100644 --- a/config/kitkat_main_dex_class_list.txt +++ b/config/kitkat_main_dex_class_list.txt @@ -33,21 +33,10 @@ org/oppia/android/app/application/ApplicationInjector.class org/oppia/android/app/application/ApplicationInjectorProvider$DefaultImpls.class org/oppia/android/app/application/ApplicationInjectorProvider.class org/oppia/android/app/application/ApplicationModule.class -org/oppia/android/app/application/ApplicationModule_ProvideApplicationContextFactory.class -org/oppia/android/app/application/ApplicationModule_ProvideContextFactory.class -org/oppia/android/app/application/DaggerApplicationComponent$1.class -org/oppia/android/app/application/DaggerApplicationComponent$ActivityComponentImplBuilder.class -org/oppia/android/app/application/DaggerApplicationComponent$ActivityComponentImplImpl$1.class -org/oppia/android/app/application/DaggerApplicationComponent$ActivityComponentImplImpl$FragmentComponentImplBuilder.class -org/oppia/android/app/application/DaggerApplicationComponent$ActivityComponentImplImpl$FragmentComponentImplImpl$1.class -org/oppia/android/app/application/DaggerApplicationComponent$ActivityComponentImplImpl$FragmentComponentImplImpl$ViewComponentImplBuilder.class -org/oppia/android/app/application/DaggerApplicationComponent$ActivityComponentImplImpl$FragmentComponentImplImpl.class -org/oppia/android/app/application/DaggerApplicationComponent$ActivityComponentImplImpl.class -org/oppia/android/app/application/DaggerApplicationComponent$Builder.class -org/oppia/android/app/application/DaggerApplicationComponent$PresentGuavaOptionalInstanceProvider.class -org/oppia/android/app/application/DaggerApplicationComponent.class -org/oppia/android/app/application/OppiaApplication$component$2.class -org/oppia/android/app/application/OppiaApplication.class +org/oppia/android/app/application/dev/DaggerDeveloperApplicationComponent$ActivityComponentImplBuilder.class +org/oppia/android/app/application/dev/DaggerDeveloperApplicationComponent$Builder.class +org/oppia/android/app/application/dev/DaggerDeveloperApplicationComponent.class +org/oppia/android/app/application/dev/DeveloperOppiaApplication.class org/oppia/android/app/translation/AppLanguageActivityInjector.class org/oppia/android/app/translation/AppLanguageActivityInjectorProvider.class org/oppia/android/app/translation/AppLanguageApplicationInjector.class diff --git a/config/proguard/kotlin-proguard-rules.pro b/config/proguard/kotlin-proguard-rules.pro index 3503b267482..7a2361a17aa 100644 --- a/config/proguard/kotlin-proguard-rules.pro +++ b/config/proguard/kotlin-proguard-rules.pro @@ -24,6 +24,11 @@ -dontwarn sun.misc.Signal -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement -# TODO(#4120): Reevaluate if these exemptions are needed long-term. --dontwarn kotlin.text.Regex$splitToSequence* --dontwarn kotlin.time.jdk8.DurationConversionsJDK8Kt +# The entirety of ClassValueCtorCache is ignored for warnings because it tries to reference an +# inherited method from java.lang.ClassValue (which isn't available in the Android SDK). It will +# eventually be an option per https://issuetracker.google.com/issues/196063118, though only on U+ +# devices. This is safe to ignore because kotlinx.coroutines avoids using ExceptionConstructors.kt +# (which houses ClassValueCtorCache & the cache it's referencing) when on Android, per: +# https://github.com/Kotlin/kotlinx.coroutines/pull/2997, specifically: +# https://github.com/Kotlin/kotlinx.coroutines/blob/3574c2/kotlinx-coroutines-core/jvm/src/internal/ExceptionsConstructor.kt#L17. +-dontwarn kotlinx.coroutines.internal.ClassValueCtorCache diff --git a/data/build.gradle b/data/build.gradle index 3f02df5e6d0..8c0c911d167 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -64,13 +64,12 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation( 'androidx.appcompat:appcompat:1.0.2', - 'com.android.support:multidex:1.0.3', - 'com.google.dagger:dagger:2.24', + 'com.google.dagger:dagger:2.41', 'com.google.guava:guava:28.1-android', 'com.google.protobuf:protobuf-javalite:3.17.3', - 'com.squareup.moshi:moshi-kotlin:1.11.0', + 'com.squareup.moshi:moshi-kotlin:1.13.0', 'com.squareup.okhttp3:okhttp:4.7.2', - 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1', + 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4', ) compileOnly( 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.2', @@ -78,15 +77,14 @@ dependencies { 'org.glassfish.jaxb:jaxb-runtime:2.3.2', ) testImplementation( - 'android.arch.core:core-testing:1.1.1', 'androidx.test.ext:junit:1.1.1', - 'com.google.dagger:dagger:2.24', + 'com.google.dagger:dagger:2.41', 'com.google.truth:truth:1.1.3', 'com.google.truth.extensions:truth-liteproto-extension:1.1.3', 'com.squareup.okhttp3:mockwebserver:4.7.2', 'com.squareup.okhttp3:okhttp:4.7.2', 'junit:junit:4.12', - 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2', + 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4', 'org.mockito:mockito-core:2.19.0', 'org.robolectric:robolectric:4.5', project(":testing"), @@ -101,11 +99,11 @@ dependencies { androidTestImplementation('androidx.test:runner:1.2.0', 'androidx.test.espresso:espresso-core:3.2.0') kapt( - 'com.google.dagger:dagger-compiler:2.24', - 'com.squareup.moshi:moshi-kotlin-codegen:1.11.0' + 'com.google.dagger:dagger-compiler:2.41', + 'com.squareup.moshi:moshi-kotlin-codegen:1.13.0' ) kaptTest( - 'com.google.dagger:dagger-compiler:2.24' + 'com.google.dagger:dagger-compiler:2.41' ) implementation project(":utility") diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index 0ff999536a3..658fd1e6df9 100755 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -141,6 +141,7 @@ kt_android_library( "//model/src/main/proto:question_java_proto_lite", "//model/src/main/proto:topic_java_proto_lite", "//third_party:androidx_work_work-runtime-ktx", + "//third_party:org_jetbrains_kotlinx_kotlinx-coroutines-guava", "//utility/src/main/java/org/oppia/android/util/data:data_providers", "//utility/src/main/java/org/oppia/android/util/extensions:bundle_extensions", "//utility/src/main/java/org/oppia/android/util/extensions:context_extensions", diff --git a/domain/build.gradle b/domain/build.gradle index 4863351dd1b..0ab591327ef 100644 --- a/domain/build.gradle +++ b/domain/build.gradle @@ -90,7 +90,7 @@ dependencies { 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03', 'androidx.lifecycle:lifecycle-extensions:2.0.0', 'androidx.work:work-runtime-ktx:2.4.0', - 'com.google.dagger:dagger:2.24', + 'com.google.dagger:dagger:2.41', 'com.google.firebase:firebase-analytics-ktx:17.5.0', 'com.google.firebase:firebase-crashlytics:17.0.0', 'com.google.firebase:firebase-firestore-ktx:24.2.1', @@ -98,6 +98,7 @@ dependencies { 'com.google.guava:guava:28.1-android', 'com.google.protobuf:protobuf-javalite:3.17.3', "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version", + 'org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.6.4' ) compileOnly( 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.2', @@ -105,27 +106,26 @@ dependencies { 'org.glassfish.jaxb:jaxb-runtime:2.3.2', ) testImplementation( - 'android.arch.core:core-testing:1.1.1', 'androidx.test.espresso:espresso-core:3.2.0', 'androidx.test.ext:junit:1.1.1', 'androidx.work:work-testing:2.4.0', - 'com.google.dagger:dagger:2.24', + 'com.google.dagger:dagger:2.41', 'com.google.truth.extensions:truth-liteproto-extension:1.1.3', 'com.google.truth:truth:1.1.3', 'com.squareup.okhttp3:mockwebserver:4.7.2', 'junit:junit:4.12', "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version", 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2', - 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2', + 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4', 'org.mockito:mockito-core:3.9.0', 'org.robolectric:robolectric:4.5', project(":testing"), ) kapt( - 'com.google.dagger:dagger-compiler:2.24', + 'com.google.dagger:dagger-compiler:2.41', ) kaptTest( - 'com.google.dagger:dagger-compiler:2.24', + 'com.google.dagger:dagger-compiler:2.41', ) // TODO(#59): Avoid needing to expose data implementations to other modules in order to make Oppia symbols // sufficiently visible for generated Dagger code. This can be done more cleanly via Bazel since dependencies can be diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationActiveTimeController.kt b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationActiveTimeController.kt index c74c7d1690d..de708122b9b 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationActiveTimeController.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationActiveTimeController.kt @@ -427,21 +427,15 @@ class ExplorationActiveTimeController @Inject constructor( message: ControllerMessage, lazyFailureMessage: () -> String ) { - // TODO(#4119): Switch this to use trySend(), instead, which is much cleaner and doesn't require - // catching an exception. - val flowResult: AsyncResult = try { - val commandQueue = mostRecentCommandQueue - when { - commandQueue == null -> - AsyncResult.Failure(IllegalStateException("Session isn't initialized yet.")) - !commandQueue.offer(message) -> - AsyncResult.Failure(IllegalStateException(lazyFailureMessage())) - // Ensure that the result is first reset since there will be a delay before the message is - // processed (if there's a flow). - else -> AsyncResult.Pending() - } - } catch (e: Exception) { - AsyncResult.Failure(e) + val commandQueue = mostRecentCommandQueue + val flowResult: AsyncResult = when { + commandQueue == null -> + AsyncResult.Failure(IllegalStateException("Session isn't initialized yet.")) + !commandQueue.trySend(message).isSuccess -> + AsyncResult.Failure(IllegalStateException(lazyFailureMessage())) + // Ensure that the result is first reset since there will be a delay before the message is + // processed (if there's a flow). + else -> AsyncResult.Pending() } // This must be assigned separately since flowResult should always be calculated, even if diff --git a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt index 533348e92df..22a64fdf412 100644 --- a/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt +++ b/domain/src/main/java/org/oppia/android/domain/exploration/ExplorationProgressController.kt @@ -530,20 +530,16 @@ class ExplorationProgressController @Inject constructor( message: ControllerMessage, lazyFailureMessage: () -> String ) { - // TODO(#4119): Switch this to use trySend(), instead, which is much cleaner and doesn't require - // catching an exception. - val flowResult: AsyncResult = try { - val commandQueue = mostRecentCommandQueue - when { - commandQueue == null -> - AsyncResult.Failure(IllegalStateException("Session isn't initialized yet.")) - !commandQueue.offer(message) -> - AsyncResult.Failure(IllegalStateException(lazyFailureMessage())) - // Ensure that the result is first reset since there will be a delay before the message is - // processed (if there's a flow). - else -> AsyncResult.Pending() - } - } catch (e: Exception) { AsyncResult.Failure(e) } + val commandQueue = mostRecentCommandQueue + val flowResult: AsyncResult = when { + commandQueue == null -> + AsyncResult.Failure(IllegalStateException("Session isn't initialized yet.")) + !commandQueue.trySend(message).isSuccess -> + AsyncResult.Failure(IllegalStateException(lazyFailureMessage())) + // Ensure that the result is first reset since there will be a delay before the message is + // processed (if there's a flow). + else -> AsyncResult.Pending() + } // This must be assigned separately since flowResult should always be calculated, even if // there's no callbackFlow to report it. diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsController.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsController.kt index 6de1f35fa92..76bac6fe92f 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsController.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsController.kt @@ -6,9 +6,9 @@ import kotlinx.coroutines.Deferred import kotlinx.coroutines.async import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.SharingStarted -import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.emitAll import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.lastOrNull import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onCompletion import kotlinx.coroutines.flow.stateIn @@ -392,17 +392,6 @@ class AnalyticsController @Inject constructor( ) } - // TODO(#4119): Migrate this to Flow.lastOrNull() once Kotlin 1.5 is available. - private suspend fun Flow.lastOrNull(): T? { - return CoroutineScope(backgroundDispatcher).async { - var lastValue: T? = null - this@lastOrNull.collect { - lastValue = it - } - return@async lastValue - }.await() - } - private companion object { private suspend fun resolveProfileOperation( profileId: ProfileId?, diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotter.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotter.kt index 6f2c90fd0cf..7bf3d657058 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotter.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotter.kt @@ -126,7 +126,7 @@ class CpuPerformanceSnapshotter( } private fun sendSwitchIconificationCommand(newIconification: AppIconification) { - commandQueue.offer(CommandMessage.SwitchIconification(newIconification)).apply { + commandQueue.trySend(CommandMessage.SwitchIconification(newIconification)).isSuccess.apply { if (!this) { val exception = IllegalStateException("Iconification switching failed") consoleLogger.e( diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/logscheduler/BUILD.bazel b/domain/src/main/java/org/oppia/android/domain/oppialogger/logscheduler/BUILD.bazel index 88e30e105bc..84b5cafd1dc 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/logscheduler/BUILD.bazel +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/logscheduler/BUILD.bazel @@ -29,6 +29,7 @@ kt_android_library( "//domain/src/main/java/org/oppia/android/domain/util:extensions", "//model/src/main/proto:screens_java_proto_lite", "//third_party:androidx_work_work-runtime-ktx", + "//third_party:org_jetbrains_kotlinx_kotlinx-coroutines-guava", "//utility/src/main/java/org/oppia/android/util/logging:console_logger", "//utility/src/main/java/org/oppia/android/util/threading:annotations", ], diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulingWorker.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulingWorker.kt index 36d1a9b05e1..3902ebb74d0 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulingWorker.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulingWorker.kt @@ -4,10 +4,10 @@ import android.content.Context import androidx.work.ListenableWorker import androidx.work.WorkerParameters import com.google.common.util.concurrent.ListenableFuture -import com.google.common.util.concurrent.SettableFuture import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.async +import kotlinx.coroutines.guava.asListenableFuture import org.oppia.android.app.model.ScreenName.BACKGROUND_SCREEN import org.oppia.android.domain.oppialogger.analytics.ApplicationLifecycleObserver import org.oppia.android.domain.oppialogger.analytics.PerformanceMetricsLogger @@ -56,25 +56,15 @@ class MetricLogSchedulingWorker private constructor( override fun startWork(): ListenableFuture { val backgroundScope = CoroutineScope(backgroundDispatcher) - val result = backgroundScope.async { + // TODO(#4463): Add withTimeout() to avoid potential hanging. + return backgroundScope.async { when (inputData.getStringFromData(WORKER_CASE_KEY)) { PERIODIC_BACKGROUND_METRIC_WORKER -> schedulePeriodicBackgroundMetricLogging() STORAGE_USAGE_WORKER -> scheduleStorageUsageMetricLogging() PERIODIC_UI_METRIC_WORKER -> schedulePeriodicUiMetricLogging() else -> Result.failure() } - } - - val future = SettableFuture.create() - result.invokeOnCompletion { failure -> - if (failure != null) { - future.setException(failure) - } else { - future.set(result.getCompleted()) - } - } - // TODO(#3715): Add withTimeout() to avoid potential hanging. - return future + }.asListenableFuture() } private fun schedulePeriodicBackgroundMetricLogging(): Result { diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader/BUILD.bazel b/domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader/BUILD.bazel index 822397af1e6..9798de724a6 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader/BUILD.bazel +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader/BUILD.bazel @@ -39,6 +39,7 @@ kt_android_library( "//domain/src/main/java/org/oppia/android/domain/util:extensions", "//third_party:androidx_work_work-runtime-ktx", "//third_party:com_google_guava_guava", + "//third_party:org_jetbrains_kotlinx_kotlinx-coroutines-guava", "//utility/src/main/java/org/oppia/android/util/logging:console_logger", "//utility/src/main/java/org/oppia/android/util/logging:event_logger", "//utility/src/main/java/org/oppia/android/util/logging:exception_logger", diff --git a/domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorker.kt b/domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorker.kt index f31669e153b..8219bf20f16 100644 --- a/domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorker.kt +++ b/domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorker.kt @@ -4,11 +4,10 @@ import android.content.Context import androidx.work.ListenableWorker import androidx.work.WorkerParameters import com.google.common.util.concurrent.ListenableFuture -import com.google.common.util.concurrent.SettableFuture import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.async +import kotlinx.coroutines.guava.asListenableFuture import org.oppia.android.domain.oppialogger.analytics.AnalyticsController import org.oppia.android.domain.oppialogger.analytics.FirestoreDataController import org.oppia.android.domain.oppialogger.analytics.PerformanceMetricsController @@ -46,10 +45,10 @@ class LogUploadWorker private constructor( const val FIRESTORE_WORKER = "firestore_worker" } - @ExperimentalCoroutinesApi override fun startWork(): ListenableFuture { val backgroundScope = CoroutineScope(backgroundDispatcher) - val result = backgroundScope.async { + // TODO(#4463): Add withTimeout() to avoid potential hanging. + return backgroundScope.async { when (inputData.getStringFromData(WORKER_CASE_KEY)) { EVENT_WORKER -> uploadEvents() EXCEPTION_WORKER -> uploadExceptions() @@ -57,18 +56,7 @@ class LogUploadWorker private constructor( FIRESTORE_WORKER -> uploadFirestoreData() else -> Result.failure() } - } - - val future = SettableFuture.create() - result.invokeOnCompletion { failure -> - if (failure != null) { - future.setException(failure) - } else { - future.set(result.getCompleted()) - } - } - // TODO(#3715): Add withTimeout() to avoid potential hanging. - return future + }.asListenableFuture() } /** Extracts exception logs from the cache store and logs them to the remote service. */ diff --git a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt index 04f1337b997..50422db85a2 100644 --- a/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt +++ b/domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt @@ -5,11 +5,10 @@ import androidx.work.ListenableWorker import androidx.work.WorkerParameters import com.google.common.base.Optional import com.google.common.util.concurrent.ListenableFuture -import com.google.common.util.concurrent.SettableFuture import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.async +import kotlinx.coroutines.guava.asListenableFuture import org.oppia.android.app.model.PlatformParameter import org.oppia.android.app.model.PlatformParameter.SyncStatus import org.oppia.android.data.backends.gae.api.PlatformParameterService @@ -54,26 +53,15 @@ class PlatformParameterSyncUpWorker private constructor( const val WORKER_TYPE_KEY = "worker_type_key" } - @ExperimentalCoroutinesApi override fun startWork(): ListenableFuture { val backgroundScope = CoroutineScope(backgroundDispatcher) - val result = backgroundScope.async { + // TODO(#4463): Add withTimeout() to avoid potential hanging. + return backgroundScope.async { when (inputData.getStringFromData(WORKER_TYPE_KEY)) { PLATFORM_PARAMETER_WORKER -> refreshPlatformParameters() else -> Result.failure() } - } - - val future = SettableFuture.create() - result.invokeOnCompletion { failure -> - if (failure != null) { - future.setException(failure) - } else { - future.set(result.getCompleted()) - } - } - // TODO(#3715): Add withTimeout() to avoid potential hanging. - return future + }.asListenableFuture() } /** diff --git a/domain/src/main/java/org/oppia/android/domain/question/QuestionAssessmentProgressController.kt b/domain/src/main/java/org/oppia/android/domain/question/QuestionAssessmentProgressController.kt index 29bc144b8cc..583ef085ce0 100644 --- a/domain/src/main/java/org/oppia/android/domain/question/QuestionAssessmentProgressController.kt +++ b/domain/src/main/java/org/oppia/android/domain/question/QuestionAssessmentProgressController.kt @@ -432,21 +432,15 @@ class QuestionAssessmentProgressController @Inject constructor( message: ControllerMessage, lazyFailureMessage: () -> String ) { - // TODO(#4119): Switch this to use trySend(), instead, which is much cleaner and doesn't require - // catching an exception. - val flowResult: AsyncResult = try { - val commandQueue = mostRecentCommandQueue - when { - commandQueue == null -> - AsyncResult.Failure(IllegalStateException("Session isn't initialized yet.")) - !commandQueue.offer(message) -> - AsyncResult.Failure(IllegalStateException(lazyFailureMessage())) - // Ensure that the result is first reset since there will be a delay before the message is - // processed (if there's a flow). - else -> AsyncResult.Pending() - } - } catch (e: Exception) { - AsyncResult.Failure(e) + val commandQueue = mostRecentCommandQueue + val flowResult: AsyncResult = when { + commandQueue == null -> + AsyncResult.Failure(IllegalStateException("Session isn't initialized yet.")) + !commandQueue.trySend(message).isSuccess -> + AsyncResult.Failure(IllegalStateException(lazyFailureMessage())) + // Ensure that the result is first reset since there will be a delay before the message is + // processed (if there's a flow). + else -> AsyncResult.Pending() } // This must be assigned separately since flowResult should always be calculated, even if diff --git a/domain/src/main/java/org/oppia/android/domain/survey/SurveyProgressController.kt b/domain/src/main/java/org/oppia/android/domain/survey/SurveyProgressController.kt index 9bc8071198e..1bb0ecec604 100644 --- a/domain/src/main/java/org/oppia/android/domain/survey/SurveyProgressController.kt +++ b/domain/src/main/java/org/oppia/android/domain/survey/SurveyProgressController.kt @@ -332,21 +332,15 @@ class SurveyProgressController @Inject constructor( message: ControllerMessage, lazyFailureMessage: () -> String ) { - // TODO(#4119): Switch this to use trySend(), instead, which is much cleaner and doesn't require - // catching an exception. - val flowResult: AsyncResult = try { - val commandQueue = mostRecentCommandQueue - when { - commandQueue == null -> - AsyncResult.Failure(IllegalStateException("Session isn't initialized yet.")) - !commandQueue.offer(message) -> - AsyncResult.Failure(IllegalStateException(lazyFailureMessage())) - // Ensure that the result is first reset since there will be a delay before the message is - // processed (if there's a flow). - else -> AsyncResult.Pending() - } - } catch (e: Exception) { - AsyncResult.Failure(e) + val commandQueue = mostRecentCommandQueue + val flowResult: AsyncResult = when { + commandQueue == null -> + AsyncResult.Failure(IllegalStateException("Session isn't initialized yet.")) + !commandQueue.trySend(message).isSuccess -> + AsyncResult.Failure(IllegalStateException(lazyFailureMessage())) + // Ensure that the result is first reset since there will be a delay before the message is + // processed (if there's a flow). + else -> AsyncResult.Pending() } // This must be assigned separately since flowResult should always be calculated, even if // there's no callbackFlow to report it. diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest.kt index c64a5fc7640..c233180629e 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest.kt @@ -19,7 +19,6 @@ import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -75,13 +74,11 @@ class AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("0==0", "answer=0", "input=0"), - Iteration("1==1", "answer=1", "input=1"), - Iteration("2==2", "answer=2", "input=2"), - Iteration("x==x", "answer=x", "input=x"), - Iteration("y==y", "answer=y", "input=y") - ) + @Iteration("0==0", "answer=0", "input=0") + @Iteration("1==1", "answer=1", "input=1") + @Iteration("2==2", "answer=2", "input=2") + @Iteration("x==x", "answer=x", "input=x") + @Iteration("y==y", "answer=y", "input=y") fun testMatches_sameSingleTerms_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -93,24 +90,22 @@ class AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("-2==-2", "answer=-2", "input=-2"), - Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14"), - Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14"), - Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3"), - Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14"), - Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14"), - Iteration("2/3==2/3", "answer=2/3", "input=2/3"), - Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14"), - Iteration("2^3==2^3", "answer=2^3", "input=2^3"), - Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14"), - Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)"), - Iteration("-x==-x", "answer=-x", "input=-x"), - Iteration("x+3.14==x+3.14", "answer=x+3.14", "input=x+3.14"), - Iteration("x-3.14==x-3.14", "answer=x-3.14", "input=x-3.14"), - Iteration("x*3.14==x*3.14", "answer=x*3.14", "input=x*3.14"), - Iteration("x/3==x/3", "answer=x/3", "input=x/3") - ) + @Iteration("-2==-2", "answer=-2", "input=-2") + @Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14") + @Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14") + @Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3") + @Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14") + @Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14") + @Iteration("2/3==2/3", "answer=2/3", "input=2/3") + @Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14") + @Iteration("2^3==2^3", "answer=2^3", "input=2^3") + @Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14") + @Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)") + @Iteration("-x==-x", "answer=-x", "input=-x") + @Iteration("x+3.14==x+3.14", "answer=x+3.14", "input=x+3.14") + @Iteration("x-3.14==x-3.14", "answer=x-3.14", "input=x-3.14") + @Iteration("x*3.14==x*3.14", "answer=x*3.14", "input=x*3.14") + @Iteration("x/3==x/3", "answer=x/3", "input=x/3") fun testMatches_sameSingleOperations_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -122,9 +117,7 @@ class AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("sqrt(x)!=sqrt(x)", "answer=sqrt(x)", "input=sqrt(x)") - ) + @Iteration("sqrt(x)!=sqrt(x)", "answer=sqrt(x)", "input=sqrt(x)") fun testMatches_sameSingleOperations_thatCannotBecomePolynomials_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -137,15 +130,13 @@ class AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1!=0", "answer=1", "input=0"), - Iteration("0!=1", "answer=0", "input=1"), - Iteration("3.14!=1", "answer=3.14", "input=1"), - Iteration("1!=3.14", "answer=1", "input=3.14"), - Iteration("x!=3.14", "answer=x", "input=3.14"), - Iteration("y!=x", "answer=y", "input=x"), - Iteration("3.14!=x", "answer=3.14", "input=x") - ) + @Iteration("1!=0", "answer=1", "input=0") + @Iteration("0!=1", "answer=0", "input=1") + @Iteration("3.14!=1", "answer=3.14", "input=1") + @Iteration("1!=3.14", "answer=1", "input=3.14") + @Iteration("x!=3.14", "answer=x", "input=3.14") + @Iteration("y!=x", "answer=y", "input=x") + @Iteration("3.14!=x", "answer=3.14", "input=x") fun testMatches_differentSingleTerms_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -157,16 +148,14 @@ class AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("3.14+1==1+3.14", "answer=3.14+1", "input=1+3.14"), - Iteration("3+2+1==1+2+3", "answer=3+2+1", "input=1+2+3"), - Iteration("-3.14+1==1-3.14", "answer=-3.14+1", "input=1-3.14"), - Iteration("3.14*2==2*3.14", "answer=3.14*2", "input=2*3.14"), - Iteration("2+x==x+2", "answer=2+x", "input=x+2"), - Iteration("y+x==x+y", "answer=y+x", "input=x+y"), - Iteration("x*2==2x", "answer=x*2", "input=2x"), - Iteration("yx==xy", "answer=yx", "input=xy") - ) + @Iteration("3.14+1==1+3.14", "answer=3.14+1", "input=1+3.14") + @Iteration("3+2+1==1+2+3", "answer=3+2+1", "input=1+2+3") + @Iteration("-3.14+1==1-3.14", "answer=-3.14+1", "input=1-3.14") + @Iteration("3.14*2==2*3.14", "answer=3.14*2", "input=2*3.14") + @Iteration("2+x==x+2", "answer=2+x", "input=x+2") + @Iteration("y+x==x+y", "answer=y+x", "input=x+y") + @Iteration("x*2==2x", "answer=x*2", "input=2x") + @Iteration("yx==xy", "answer=yx", "input=xy") fun testMatches_operationsDiffer_byCommutativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -178,14 +167,12 @@ class AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1+(2+3)==(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3"), - Iteration("2*(3*4)==(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4"), - Iteration("x+(2+3)==(x+2)+3", "answer=x+(2+3)", "input=(x+2)+3"), - Iteration("x+(y+z)==(x+y)+z", "answer=x+(y+z)", "input=(x+y)+z"), - Iteration("2*(3x)==(2x)*3", "answer=2*(3x)", "input=(2x)*3"), - Iteration("x(yz)==(xy)z", "answer=x(yz)", "input=(xy)z") - ) + @Iteration("1+(2+3)==(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3") + @Iteration("2*(3*4)==(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4") + @Iteration("x+(2+3)==(x+2)+3", "answer=x+(2+3)", "input=(x+2)+3") + @Iteration("x+(y+z)==(x+y)+z", "answer=x+(y+z)", "input=(x+y)+z") + @Iteration("2*(3x)==(2x)*3", "answer=2*(3x)", "input=(2x)*3") + @Iteration("x(yz)==(xy)z", "answer=x(yz)", "input=(xy)z") fun testMatches_operationsDiffer_byAssociativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -197,17 +184,15 @@ class AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14"), - Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3"), - Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14"), - Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4"), - Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14"), - Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14"), - Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z"), - Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14"), - Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") - ) + @Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14") + @Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3") + @Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14") + @Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4") + @Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14") + @Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14") + @Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z") + @Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14") + @Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") fun testMatches_operationsDiffer_byNonCommutativeOrAssociativeReordering_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -220,26 +205,24 @@ class AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1-2==-(2-1)", "answer=1-2", "input=-(2-1)"), - Iteration("1+2==1+1+1", "answer=1+2", "input=1+1+1"), - Iteration("1+2==1-(-2)", "answer=1+2", "input=1-(-2)"), - Iteration("4-6==1-2-1", "answer=4-6", "input=1-2-1"), - Iteration("2*3*2*2==2*3*4", "answer=2*3*2*2", "input=2*3*4"), - Iteration("-6-2==2*-(3+1)", "answer=-6-2", "input=2*-(3+1)"), - Iteration("2/3/2/2==2/3/4", "answer=2/3/2/2", "input=2/3/4"), - Iteration("2^(2+1)==2^3", "answer=2^(2+1)", "input=2^3"), - Iteration("2^(-1)==1/2", "answer=2^(-1)", "input=1/2"), - Iteration("x-y==-(y-x)", "answer=x-y", "input=-(y-x)"), - Iteration("2+x==1+x+1", "answer=2+x", "input=1+x+1"), - Iteration("1+x==1-(-x)", "answer=1+x", "input=1-(-x)"), - Iteration("-x==1-x-1", "answer=-x", "input=1-x-1"), - Iteration("4x==2*2*x", "answer=4x", "input=2*2*x"), - Iteration("2-6x==2*(-3x+1)", "answer=2-6x", "input=2*(-3x+1)"), - Iteration("x/4==x/2/2", "answer=x/4", "input=x/2/2"), - Iteration("x^(2+1)==x^3", "answer=x^(2+1)", "input=x^3"), - Iteration("x*(2^(-1))==x/2", "answer=x*(2^(-1))", "input=x/2") - ) + @Iteration("1-2==-(2-1)", "answer=1-2", "input=-(2-1)") + @Iteration("1+2==1+1+1", "answer=1+2", "input=1+1+1") + @Iteration("1+2==1-(-2)", "answer=1+2", "input=1-(-2)") + @Iteration("4-6==1-2-1", "answer=4-6", "input=1-2-1") + @Iteration("2*3*2*2==2*3*4", "answer=2*3*2*2", "input=2*3*4") + @Iteration("-6-2==2*-(3+1)", "answer=-6-2", "input=2*-(3+1)") + @Iteration("2/3/2/2==2/3/4", "answer=2/3/2/2", "input=2/3/4") + @Iteration("2^(2+1)==2^3", "answer=2^(2+1)", "input=2^3") + @Iteration("2^(-1)==1/2", "answer=2^(-1)", "input=1/2") + @Iteration("x-y==-(y-x)", "answer=x-y", "input=-(y-x)") + @Iteration("2+x==1+x+1", "answer=2+x", "input=1+x+1") + @Iteration("1+x==1-(-x)", "answer=1+x", "input=1-(-x)") + @Iteration("-x==1-x-1", "answer=-x", "input=1-x-1") + @Iteration("4x==2*2*x", "answer=4x", "input=2*2*x") + @Iteration("2-6x==2*(-3x+1)", "answer=2-6x", "input=2*(-3x+1)") + @Iteration("x/4==x/2/2", "answer=x/4", "input=x/2/2") + @Iteration("x^(2+1)==x^3", "answer=x^(2+1)", "input=x^3") + @Iteration("x*(2^(-1))==x/2", "answer=x*(2^(-1))", "input=x/2") fun testMatches_operationsDiffer_byDistributionAndCombining_returnTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -251,268 +234,266 @@ class AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("3x(3x - 2) + 1==(3x-1)^2", "answer=3x(3x - 2) + 1", "input=(3x-1)^2"), - Iteration("3(3x^2) - 6x +1==(3x-1)^2", "answer=3(3x^2) - 6x +1", "input=(3x-1)^2"), - Iteration("(1 - 3x)^2!=(3x-1)^2", "answer=(1 - 3x)^2", "input=(3x-1)^2"), - Iteration("2x==sqrt(4x^2)", "answer=2x", "input=sqrt(4x^2)"), - Iteration("x^2+2x+1==(x+1)^2", "answer=x^2+2x+1", "input=(x+1)^2"), - Iteration("x^2-1==(x+1)(x-1)", "answer=x^2-1", "input=(x+1)(x-1)"), - Iteration("x+1==(x^2+2x+1)/(x+1)", "answer=x+1", "input=(x^2+2x+1)/(x+1)"), - Iteration("x-1==(x^2-1)/(x+1)", "answer=x-1", "input=(x^2-1)/(x+1)"), - Iteration("x+1==(x^2-1)/(x-1)", "answer=x+1", "input=(x^2-1)/(x-1)"), - Iteration("-3x==(-27x^3)^(1/3)", "answer=-3x", "input=(-27x^3)^(1/3)"), - Iteration("1==(x^2-1)/(x^2-1)", "answer=1", "input=(x^2-1)/(x^2-1)"), - Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration( - "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2 × (50 + 150 + 100 + 25) ==(50 + 150 + 100 + 25) × 2", - "answer=2 × (50 + 150 + 100 + 25) ", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration( - "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", - "answer=2 * (50 + 150 + 100 + 25) ", - "input=2 × (50 + 150 + 100 + 25)" - ), - Iteration("2+5==5+2", "answer=2+5", "input=5+2"), - Iteration("5+2==5+2", "answer=5+2", "input=5+2"), - Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)"), - Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)"), - Iteration("− (− 4) + 6==6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)"), - Iteration("10==6 − (− 4)", "answer=10", "input=6 − (− 4)"), - Iteration("6 + 4==6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)"), - Iteration("6 + 2^2==6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)"), - Iteration("3 * 2 − (− 4)==6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)"), - Iteration("100/10==6 − (− 4)", "answer=100/10", "input=6 − (− 4)"), - Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5"), - Iteration("3/(10 * 10^4)==3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5"), - Iteration( - "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "200 + 30 + 4 + 0.5 + 0.06 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "0.06 + 0.5 + 4 + 30 + 200 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1234.56==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "123456/100==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456/100", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "61728/50==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=61728/50", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1234 + 56/100==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234 + 56/100", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1230 + 4.56==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1230 + 4.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration( - "2 * 2 * 3 * 3 * 1==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" - ), - Iteration("2 * 2 * 9==2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3"), - Iteration("4 * 3^2==2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3"), - Iteration("8/2 * 3 * 3==2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration("36==2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3"), - Iteration("sqrt(4-2)==sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)"), - Iteration("4x^2+20x==4*x^2+20x", "answer=4x^2+20x", "input=4*x^2+20x"), - Iteration("3+x-5==3+x-5", "answer=3+x-5", "input=3+x-5"), - Iteration("Z+A-Z==Z+A-Z", "answer=Z+A-Z", "input=Z+A-Z"), - Iteration("6C - 5A -1==6C - 5A -1", "answer=6C - 5A -1", "input=6C - 5A -1"), - Iteration("5Z-w==5*Z-w", "answer=5Z-w", "input=5*Z-w"), - Iteration("5*Z-w==5*Z-w", "answer=5*Z-w", "input=5*Z-w"), - Iteration("LS-3S+L==L*S-3S+L", "answer=LS-3S+L", "input=L*S-3S+L"), - Iteration("L*S-3S+L==L*S-3S+L", "answer=L*S-3S+L", "input=L*S-3S+L"), - Iteration("L*S-3*S+L==L*S-3S+L", "answer=L*S-3*S+L", "input=L*S-3S+L"), - Iteration("LS-3*S+L==L*S-3S+L", "answer=LS-3*S+L", "input=L*S-3S+L"), - Iteration("9x^2 − 6x + 1==9x^2 − 6x + 1", "answer=9x^2 − 6x + 1", "input=9x^2 − 6x + 1"), - Iteration("c*b-c==c*b-c", "answer=c*b-c", "input=c*b-c"), - Iteration("bc-c==c*b-c", "answer=bc-c", "input=c*b-c"), - Iteration("cb-c==c*b-c", "answer=cb-c", "input=c*b-c"), - Iteration("-c+bc==c*b-c", "answer=-c+bc", "input=c*b-c"), - Iteration("-c+cb==c*b-c", "answer=-c+cb", "input=c*b-c"), - Iteration("x^2+y+4x==x^2+y+4x", "answer=x^2+y+4x", "input=x^2+y+4x"), - Iteration("y+4x+x^2==x^2+y+4x", "answer=y+4x+x^2", "input=x^2+y+4x"), - Iteration("x^2+4x+y==x^2+y+4x", "answer=x^2+4x+y", "input=x^2+y+4x"), - Iteration("Y+5==Y+5", "answer=Y+5", "input=Y+5"), - Iteration("5+Y==Y+5", "answer=5+Y", "input=Y+5"), - Iteration( - "a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "2a*b + 2bc + 2a*c + a^2 + b^2 + c^2==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=2a*b + 2bc + 2a*c + a^2 + b^2 + c^2", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(a+ b)^2 + c^2 + 2bc + 2a*c==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(a+ b)^2 + c^2 + 2bc + 2a*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(a+b+c)^2==a^2+b^2+c^2+2a*b+2a*c+2bc", "answer=(a+b+c)^2", "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(-a -b -c)^2==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(-a -b -c)^2", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration("1 - 6x + 9x^2==9x^2 − 6x + 1", "answer=1 - 6x + 9x^2", "input=9x^2 − 6x + 1"), - Iteration("9x^2 + 1 - 6x==9x^2 − 6x + 1", "answer=9x^2 + 1 - 6x", "input=9x^2 − 6x + 1"), - Iteration("2+1+x==x+1+2", "answer=2+1+x", "input=x+1+2"), - Iteration("1+2+x==x+1+2", "answer=1+2+x", "input=x+1+2"), - Iteration("1+x+2==x+1+2", "answer=1+x+2", "input=x+1+2"), - Iteration("2+x+1==x+1+2", "answer=2+x+1", "input=x+1+2"), - Iteration("(x+1)+2==x+1+2", "answer=(x+1)+2", "input=x+1+2"), - Iteration("x + (1+2)==x+1+2", "answer=x + (1+2)", "input=x+1+2"), - Iteration( - "y+1+ 9x(x − 6)==9x(x − 6) + 1+ y", "answer=y+1+ 9x(x − 6)", "input=9x(x − 6) + 1+ y" - ), - Iteration("1+y+9x(x − 6)==9x(x − 6) + 1+ y", "answer=1+y+9x(x − 6)", "input=9x(x − 6) + 1+ y"), - Iteration( - "1 + 9x(x − 6) + y==9x(x − 6) + 1+ y", "answer=1 + 9x(x − 6) + y", "input=9x(x − 6) + 1+ y" - ), - Iteration( - "(y+1)+9x(x − 6)==9x(x − 6) + 1+ y", "answer=(y+1)+9x(x − 6)", "input=9x(x − 6) + 1+ y" - ), - Iteration( - "(x^2 − x)/3 − 4y==(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "-4y + (x^2 − x)/3==(x^2 − x)/3 − 4y", "answer=-4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "x(x − 1)/3 −4y==(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 −4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "x^2/3 − x/3 − 4y==(x^2 − x)/3 − 4y", "answer=x^2/3 − x/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "x^2/3 − (x/3 + 4y)==(x^2 − x)/3 − 4y", "answer=x^2/3 − (x/3 + 4y)", "input=(x^2 − x)/3 − 4y" - ), - Iteration("(3x -1)^2==(3x-1)^2", "answer=(3x -1)^2", "input=(3x-1)^2"), - Iteration("2*(6+3+4) + 4==2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)"), - Iteration("2*(2+6+3) + 8==2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)"), - Iteration("(2+6+3+4)*2==2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)"), - Iteration("(2+6+3+4) × 2==2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)"), - Iteration("15 - 12 + 3==15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3"), - Iteration( - "3 - (6 * 2) + 15==15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" - ), - Iteration( - "15 - (2 × 6) + 3==15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2 *(50 + 150) + 2*(100 + 25)==(50 + 150 + 100 + 25) × 2", - "answer=2 *(50 + 150) + 2*(100 + 25)", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration( - "2* ( 25+50+100+150)==(50 + 150 + 100 + 25) × 2", - "answer=2* ( 25+50+100+150)", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration("10^−5 * 3==3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5"), - Iteration("30 * 10^−6==3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5"), - Iteration("0.00003==3 * 10^-5", "answer=0.00003", "input=3 * 10^-5"), - Iteration("3/10^5==3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5"), - Iteration("3 *2 – (− 4)==6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)"), - Iteration("7==5+2", "answer=7", "input=5+2"), - Iteration("3+4==5+2", "answer=3+4", "input=5+2"), - Iteration("20x+4x^2==4*x^2+20x", "answer=20x+4x^2", "input=4*x^2+20x"), - Iteration("x-5+3==3+x-5", "answer=x-5+3", "input=3+x-5"), - Iteration("-5+3+x==3+x-5", "answer=-5+3+x", "input=3+x-5"), - Iteration("-5+x+3==3+x-5", "answer=-5+x+3", "input=3+x-5"), - Iteration("3+(x-5)==3+x-5", "answer=3+(x-5)", "input=3+x-5"), - Iteration("A==Z+A-Z", "answer=A", "input=Z+A-Z"), - Iteration("A+Z-Z==Z+A-Z", "answer=A+Z-Z", "input=Z+A-Z"), - Iteration("Z+(A-Z)==Z+A-Z", "answer=Z+(A-Z)", "input=Z+A-Z"), - Iteration("6C - (5A+1)==6C - 5A -1", "answer=6C - (5A+1)", "input=6C - 5A -1"), - Iteration("-5A-1+6C==6C - 5A -1", "answer=-5A-1+6C", "input=6C - 5A -1"), - Iteration("-W+5Z==5*Z-W", "answer=-W+5Z", "input=5*Z-W"), - Iteration("L(1+S)-3S==L*S-3S+L", "answer=L(1+S)-3S", "input=L*S-3S+L"), - Iteration("S(L-3)+L==L*S-3S+L", "answer=S(L-3)+L", "input=L*S-3S+L"), - Iteration("L+LS-3S==L*S-3S+L", "answer=L+LS-3S", "input=L*S-3S+L"), - Iteration( - "x(x − 1)/3 − 4y==(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "- 4y + (x^2 − x)/3==(x^2 − x)/3 − 4y", "answer=- 4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 − x) * 3^-1 − 4y==(x^2 − x)/3 − 4y", - "answer=(x^2 − x) * 3^-1 − 4y", - "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "a^2 + b^2 + c^2 + 2(a*b + a*c + bc)==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2 + 2(a*b + a*c + bc)", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(a + b)^2 + c^2 + 2a*c + 2bc==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(a + b)^2 + c^2 + 2a*c + 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration("(3x − 1)^2==9x^2 − 6x + 1", "answer=(3x − 1)^2", "input=9x^2 − 6x + 1"), - Iteration("3x(3x − 2) + 1==9x^2 − 6x + 1", "answer=3x(3x − 2) + 1", "input=9x^2 − 6x + 1"), - Iteration("3(3x^2 − 2x) + 1==9x^2 − 6x + 1", "answer=3(3x^2 − 2x) + 1", "input=9x^2 − 6x + 1"), - Iteration("(3x)^2 − 6x + 1==9x^2 − 6x + 1", "answer=(3x)^2 − 6x + 1", "input=9x^2 − 6x + 1"), - Iteration("c(b-1)==c*b-c", "answer=c(b-1)", "input=c*b-c"), - Iteration("x(x+4)+y==x^2+y+4x", "answer=x(x+4)+y", "input=x^2+y+4x"), - Iteration("x+3==x+1+2", "answer=x+3", "input=x+1+2") + @Iteration("3x(3x - 2) + 1==(3x-1)^2", "answer=3x(3x - 2) + 1", "input=(3x-1)^2") + @Iteration("3(3x^2) - 6x +1==(3x-1)^2", "answer=3(3x^2) - 6x +1", "input=(3x-1)^2") + @Iteration("(1 - 3x)^2!=(3x-1)^2", "answer=(1 - 3x)^2", "input=(3x-1)^2") + @Iteration("2x==sqrt(4x^2)", "answer=2x", "input=sqrt(4x^2)") + @Iteration("x^2+2x+1==(x+1)^2", "answer=x^2+2x+1", "input=(x+1)^2") + @Iteration("x^2-1==(x+1)(x-1)", "answer=x^2-1", "input=(x+1)(x-1)") + @Iteration("x+1==(x^2+2x+1)/(x+1)", "answer=x+1", "input=(x^2+2x+1)/(x+1)") + @Iteration("x-1==(x^2-1)/(x+1)", "answer=x-1", "input=(x^2-1)/(x+1)") + @Iteration("x+1==(x^2-1)/(x-1)", "answer=x+1", "input=(x^2-1)/(x-1)") + @Iteration("-3x==(-27x^3)^(1/3)", "answer=-3x", "input=(-27x^3)^(1/3)") + @Iteration("1==(x^2-1)/(x^2-1)", "answer=1", "input=(x^2-1)/(x^2-1)") + @Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration( + "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "2 × (50 + 150 + 100 + 25) ==(50 + 150 + 100 + 25) × 2", + "answer=2 × (50 + 150 + 100 + 25) ", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration( + "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", + "answer=2 * (50 + 150 + 100 + 25) ", + "input=2 × (50 + 150 + 100 + 25)" + ) + @Iteration("2+5==5+2", "answer=2+5", "input=5+2") + @Iteration("5+2==5+2", "answer=5+2", "input=5+2") + @Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)") + @Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)") + @Iteration("− (− 4) + 6==6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)") + @Iteration("10==6 − (− 4)", "answer=10", "input=6 − (− 4)") + @Iteration("6 + 4==6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)") + @Iteration("6 + 2^2==6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)") + @Iteration("3 * 2 − (− 4)==6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)") + @Iteration("100/10==6 − (− 4)", "answer=100/10", "input=6 − (− 4)") + @Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5") + @Iteration("3/(10 * 10^4)==3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5") + @Iteration( + "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "200 + 30 + 4 + 0.5 + 0.06 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "0.06 + 0.5 + 4 + 30 + 200 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1234.56==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "123456/100==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456/100", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "61728/50==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=61728/50", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1234 + 56/100==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234 + 56/100", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1230 + 4.56==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1230 + 4.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration( + "2 * 2 * 3 * 3 * 1==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" + ) + @Iteration("2 * 2 * 9==2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3") + @Iteration("4 * 3^2==2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3") + @Iteration("8/2 * 3 * 3==2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("36==2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3") + @Iteration("sqrt(4-2)==sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)") + @Iteration("4x^2+20x==4*x^2+20x", "answer=4x^2+20x", "input=4*x^2+20x") + @Iteration("3+x-5==3+x-5", "answer=3+x-5", "input=3+x-5") + @Iteration("Z+A-Z==Z+A-Z", "answer=Z+A-Z", "input=Z+A-Z") + @Iteration("6C - 5A -1==6C - 5A -1", "answer=6C - 5A -1", "input=6C - 5A -1") + @Iteration("5Z-w==5*Z-w", "answer=5Z-w", "input=5*Z-w") + @Iteration("5*Z-w==5*Z-w", "answer=5*Z-w", "input=5*Z-w") + @Iteration("LS-3S+L==L*S-3S+L", "answer=LS-3S+L", "input=L*S-3S+L") + @Iteration("L*S-3S+L==L*S-3S+L", "answer=L*S-3S+L", "input=L*S-3S+L") + @Iteration("L*S-3*S+L==L*S-3S+L", "answer=L*S-3*S+L", "input=L*S-3S+L") + @Iteration("LS-3*S+L==L*S-3S+L", "answer=LS-3*S+L", "input=L*S-3S+L") + @Iteration("9x^2 − 6x + 1==9x^2 − 6x + 1", "answer=9x^2 − 6x + 1", "input=9x^2 − 6x + 1") + @Iteration("c*b-c==c*b-c", "answer=c*b-c", "input=c*b-c") + @Iteration("bc-c==c*b-c", "answer=bc-c", "input=c*b-c") + @Iteration("cb-c==c*b-c", "answer=cb-c", "input=c*b-c") + @Iteration("-c+bc==c*b-c", "answer=-c+bc", "input=c*b-c") + @Iteration("-c+cb==c*b-c", "answer=-c+cb", "input=c*b-c") + @Iteration("x^2+y+4x==x^2+y+4x", "answer=x^2+y+4x", "input=x^2+y+4x") + @Iteration("y+4x+x^2==x^2+y+4x", "answer=y+4x+x^2", "input=x^2+y+4x") + @Iteration("x^2+4x+y==x^2+y+4x", "answer=x^2+4x+y", "input=x^2+y+4x") + @Iteration("Y+5==Y+5", "answer=Y+5", "input=Y+5") + @Iteration("5+Y==Y+5", "answer=5+Y", "input=Y+5") + @Iteration( + "a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "2a*b + 2bc + 2a*c + a^2 + b^2 + c^2==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=2a*b + 2bc + 2a*c + a^2 + b^2 + c^2", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(a+ b)^2 + c^2 + 2bc + 2a*c==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(a+ b)^2 + c^2 + 2bc + 2a*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(a+b+c)^2==a^2+b^2+c^2+2a*b+2a*c+2bc", "answer=(a+b+c)^2", "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(-a -b -c)^2==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(-a -b -c)^2", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" ) + @Iteration("1 - 6x + 9x^2==9x^2 − 6x + 1", "answer=1 - 6x + 9x^2", "input=9x^2 − 6x + 1") + @Iteration("9x^2 + 1 - 6x==9x^2 − 6x + 1", "answer=9x^2 + 1 - 6x", "input=9x^2 − 6x + 1") + @Iteration("2+1+x==x+1+2", "answer=2+1+x", "input=x+1+2") + @Iteration("1+2+x==x+1+2", "answer=1+2+x", "input=x+1+2") + @Iteration("1+x+2==x+1+2", "answer=1+x+2", "input=x+1+2") + @Iteration("2+x+1==x+1+2", "answer=2+x+1", "input=x+1+2") + @Iteration("(x+1)+2==x+1+2", "answer=(x+1)+2", "input=x+1+2") + @Iteration("x + (1+2)==x+1+2", "answer=x + (1+2)", "input=x+1+2") + @Iteration( + "y+1+ 9x(x − 6)==9x(x − 6) + 1+ y", "answer=y+1+ 9x(x − 6)", "input=9x(x − 6) + 1+ y" + ) + @Iteration("1+y+9x(x − 6)==9x(x − 6) + 1+ y", "answer=1+y+9x(x − 6)", "input=9x(x − 6) + 1+ y") + @Iteration( + "1 + 9x(x − 6) + y==9x(x − 6) + 1+ y", "answer=1 + 9x(x − 6) + y", "input=9x(x − 6) + 1+ y" + ) + @Iteration( + "(y+1)+9x(x − 6)==9x(x − 6) + 1+ y", "answer=(y+1)+9x(x − 6)", "input=9x(x − 6) + 1+ y" + ) + @Iteration( + "(x^2 − x)/3 − 4y==(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "-4y + (x^2 − x)/3==(x^2 − x)/3 − 4y", "answer=-4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "x(x − 1)/3 −4y==(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 −4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "x^2/3 − x/3 − 4y==(x^2 − x)/3 − 4y", "answer=x^2/3 − x/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "x^2/3 − (x/3 + 4y)==(x^2 − x)/3 − 4y", "answer=x^2/3 − (x/3 + 4y)", "input=(x^2 − x)/3 − 4y" + ) + @Iteration("(3x -1)^2==(3x-1)^2", "answer=(3x -1)^2", "input=(3x-1)^2") + @Iteration("2*(6+3+4) + 4==2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)") + @Iteration("2*(2+6+3) + 8==2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)") + @Iteration("(2+6+3+4)*2==2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)") + @Iteration("(2+6+3+4) × 2==2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)") + @Iteration("15 - 12 + 3==15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3") + @Iteration( + "3 - (6 * 2) + 15==15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "15 - (2 × 6) + 3==15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "2 *(50 + 150) + 2*(100 + 25)==(50 + 150 + 100 + 25) × 2", + "answer=2 *(50 + 150) + 2*(100 + 25)", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration( + "2* ( 25+50+100+150)==(50 + 150 + 100 + 25) × 2", + "answer=2* ( 25+50+100+150)", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration("10^−5 * 3==3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5") + @Iteration("30 * 10^−6==3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5") + @Iteration("0.00003==3 * 10^-5", "answer=0.00003", "input=3 * 10^-5") + @Iteration("3/10^5==3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5") + @Iteration("3 *2 – (− 4)==6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)") + @Iteration("7==5+2", "answer=7", "input=5+2") + @Iteration("3+4==5+2", "answer=3+4", "input=5+2") + @Iteration("20x+4x^2==4*x^2+20x", "answer=20x+4x^2", "input=4*x^2+20x") + @Iteration("x-5+3==3+x-5", "answer=x-5+3", "input=3+x-5") + @Iteration("-5+3+x==3+x-5", "answer=-5+3+x", "input=3+x-5") + @Iteration("-5+x+3==3+x-5", "answer=-5+x+3", "input=3+x-5") + @Iteration("3+(x-5)==3+x-5", "answer=3+(x-5)", "input=3+x-5") + @Iteration("A==Z+A-Z", "answer=A", "input=Z+A-Z") + @Iteration("A+Z-Z==Z+A-Z", "answer=A+Z-Z", "input=Z+A-Z") + @Iteration("Z+(A-Z)==Z+A-Z", "answer=Z+(A-Z)", "input=Z+A-Z") + @Iteration("6C - (5A+1)==6C - 5A -1", "answer=6C - (5A+1)", "input=6C - 5A -1") + @Iteration("-5A-1+6C==6C - 5A -1", "answer=-5A-1+6C", "input=6C - 5A -1") + @Iteration("-W+5Z==5*Z-W", "answer=-W+5Z", "input=5*Z-W") + @Iteration("L(1+S)-3S==L*S-3S+L", "answer=L(1+S)-3S", "input=L*S-3S+L") + @Iteration("S(L-3)+L==L*S-3S+L", "answer=S(L-3)+L", "input=L*S-3S+L") + @Iteration("L+LS-3S==L*S-3S+L", "answer=L+LS-3S", "input=L*S-3S+L") + @Iteration( + "x(x − 1)/3 − 4y==(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "- 4y + (x^2 − x)/3==(x^2 − x)/3 − 4y", "answer=- 4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 − x) * 3^-1 − 4y==(x^2 − x)/3 − 4y", + "answer=(x^2 − x) * 3^-1 − 4y", + "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "a^2 + b^2 + c^2 + 2(a*b + a*c + bc)==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2 + 2(a*b + a*c + bc)", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(a + b)^2 + c^2 + 2a*c + 2bc==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(a + b)^2 + c^2 + 2a*c + 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration("(3x − 1)^2==9x^2 − 6x + 1", "answer=(3x − 1)^2", "input=9x^2 − 6x + 1") + @Iteration("3x(3x − 2) + 1==9x^2 − 6x + 1", "answer=3x(3x − 2) + 1", "input=9x^2 − 6x + 1") + @Iteration("3(3x^2 − 2x) + 1==9x^2 − 6x + 1", "answer=3(3x^2 − 2x) + 1", "input=9x^2 − 6x + 1") + @Iteration("(3x)^2 − 6x + 1==9x^2 − 6x + 1", "answer=(3x)^2 − 6x + 1", "input=9x^2 − 6x + 1") + @Iteration("c(b-1)==c*b-c", "answer=c(b-1)", "input=c*b-c") + @Iteration("x(x+4)+y==x^2+y+4x", "answer=x(x+4)+y", "input=x^2+y+4x") + @Iteration("x+3==x+1+2", "answer=x+3", "input=x+1+2") fun testMatches_assortedExpressions_withMatchingCharacteristics_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -525,68 +506,66 @@ class AlgebraicExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("√(3x −1)4!=(3x-1)^2", "answer=√(3x −1)4", "input=(3x-1)^2"), - Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5"), - Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5"), - Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5"), - Iteration( - "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)"), - Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)"), - Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)"), - Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3"), - Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration( - "x(x^2 − x)/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 − x)/3 + 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 + 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 + x)/3 - 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 + x)/3 - 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 − x)*0.33 - 4y!=(x^2 − x)/3 − 4y", - "answer=(x^2 − x)*0.33 - 4y", - "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(a + b + c)^3!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(a + b + c)^3", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a^2 + b^2 + c^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration("9x^2 - 6x - 1!=(3x-1)^2", "answer=9x^2 - 6x - 1", "input=(3x-1)^2"), - Iteration("(3x −1)!=(3x-1)^2", "answer=(3x −1)", "input=(3x-1)^2"), - Iteration("2x!=sqrt(2x)^2", "answer=2x", "input=sqrt(2x)^2"), - Iteration("2x!=sqrt(-4x^2)", "answer=2x", "input=sqrt(-4x^2)"), - Iteration("x^2+2x+1!=(x+2)^2", "answer=x^2+2x+1", "input=(x+2)^2"), - Iteration("x^2-1!=(x+1)(1-x)", "answer=x^2-1", "input=(x+1)(1-x)"), - Iteration("x+1!=(x^2+2x+1)/(x-1)", "answer=x+1", "input=(x^2+2x+1)/(x-1)"), - Iteration("x-1!=(x^2-1)/x", "answer=x-1", "input=(x^2-1)/x"), - Iteration("x+1!=(x^2-1)/(x-2)", "answer=x+1", "input=(x^2-1)/(x-2)"), - Iteration("-3x!=(9x^3)^(1/3)", "answer=-3x", "input=(9x^3)^(1/3)"), - Iteration("Y==Y+5", "answer=Y", "input=Y+5"), - Iteration("5==Y+5", "answer=5", "input=Y+5") + @Iteration("√(3x −1)4!=(3x-1)^2", "answer=√(3x −1)4", "input=(3x-1)^2") + @Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5") + @Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5") + @Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5") + @Iteration( + "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)") + @Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)") + @Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)") + @Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3") + @Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration( + "x(x^2 − x)/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 − x)/3 + 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 + 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 + x)/3 - 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 + x)/3 - 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 − x)*0.33 - 4y!=(x^2 − x)/3 − 4y", + "answer=(x^2 − x)*0.33 - 4y", + "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(a + b + c)^3!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(a + b + c)^3", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a^2 + b^2 + c^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" ) + @Iteration("9x^2 - 6x - 1!=(3x-1)^2", "answer=9x^2 - 6x - 1", "input=(3x-1)^2") + @Iteration("(3x −1)!=(3x-1)^2", "answer=(3x −1)", "input=(3x-1)^2") + @Iteration("2x!=sqrt(2x)^2", "answer=2x", "input=sqrt(2x)^2") + @Iteration("2x!=sqrt(-4x^2)", "answer=2x", "input=sqrt(-4x^2)") + @Iteration("x^2+2x+1!=(x+2)^2", "answer=x^2+2x+1", "input=(x+2)^2") + @Iteration("x^2-1!=(x+1)(1-x)", "answer=x^2-1", "input=(x+1)(1-x)") + @Iteration("x+1!=(x^2+2x+1)/(x-1)", "answer=x+1", "input=(x^2+2x+1)/(x-1)") + @Iteration("x-1!=(x^2-1)/x", "answer=x-1", "input=(x^2-1)/x") + @Iteration("x+1!=(x^2-1)/(x-2)", "answer=x+1", "input=(x^2-1)/(x-2)") + @Iteration("-3x!=(9x^3)^(1/3)", "answer=-3x", "input=(9x^3)^(1/3)") + @Iteration("Y==Y+5", "answer=Y", "input=Y+5") + @Iteration("5==Y+5", "answer=5", "input=Y+5") fun testMatches_assortedExpressions_withoutMatchingCharacteristics_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt index 0511f4c6d0a..624d16d2a0a 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt @@ -19,7 +19,6 @@ import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -76,13 +75,11 @@ class AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("0==0", "answer=0", "input=0"), - Iteration("1==1", "answer=1", "input=1"), - Iteration("2==2", "answer=2", "input=2"), - Iteration("x==x", "answer=x", "input=x"), - Iteration("y==y", "answer=y", "input=y") - ) + @Iteration("0==0", "answer=0", "input=0") + @Iteration("1==1", "answer=1", "input=1") + @Iteration("2==2", "answer=2", "input=2") + @Iteration("x==x", "answer=x", "input=x") + @Iteration("y==y", "answer=y", "input=y") fun testMatches_sameSingleTerms_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -94,25 +91,23 @@ class AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("-2==-2", "answer=-2", "input=-2"), - Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14"), - Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14"), - Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3"), - Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14"), - Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14"), - Iteration("2/3==2/3", "answer=2/3", "input=2/3"), - Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14"), - Iteration("2^3==2^3", "answer=2^3", "input=2^3"), - Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14"), - Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)"), - Iteration("-x==-x", "answer=-x", "input=-x"), - Iteration("x+3.14==x+3.14", "answer=x+3.14", "input=x+3.14"), - Iteration("x-3.14==x-3.14", "answer=x-3.14", "input=x-3.14"), - Iteration("x*3.14==x*3.14", "answer=x*3.14", "input=x*3.14"), - Iteration("x/3==x/3", "answer=x/3", "input=x/3"), - Iteration("sqrt(x)==sqrt(x)", "answer=sqrt(x)", "input=sqrt(x)") - ) + @Iteration("-2==-2", "answer=-2", "input=-2") + @Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14") + @Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14") + @Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3") + @Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14") + @Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14") + @Iteration("2/3==2/3", "answer=2/3", "input=2/3") + @Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14") + @Iteration("2^3==2^3", "answer=2^3", "input=2^3") + @Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14") + @Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)") + @Iteration("-x==-x", "answer=-x", "input=-x") + @Iteration("x+3.14==x+3.14", "answer=x+3.14", "input=x+3.14") + @Iteration("x-3.14==x-3.14", "answer=x-3.14", "input=x-3.14") + @Iteration("x*3.14==x*3.14", "answer=x*3.14", "input=x*3.14") + @Iteration("x/3==x/3", "answer=x/3", "input=x/3") + @Iteration("sqrt(x)==sqrt(x)", "answer=sqrt(x)", "input=sqrt(x)") fun testMatches_sameSingleOperations_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -124,15 +119,13 @@ class AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1!=0", "answer=1", "input=0"), - Iteration("0!=1", "answer=0", "input=1"), - Iteration("3.14!=1", "answer=3.14", "input=1"), - Iteration("1!=3.14", "answer=1", "input=3.14"), - Iteration("x!=3.14", "answer=x", "input=3.14"), - Iteration("y!=x", "answer=y", "input=x"), - Iteration("3.14!=x", "answer=3.14", "input=x") - ) + @Iteration("1!=0", "answer=1", "input=0") + @Iteration("0!=1", "answer=0", "input=1") + @Iteration("3.14!=1", "answer=3.14", "input=1") + @Iteration("1!=3.14", "answer=1", "input=3.14") + @Iteration("x!=3.14", "answer=x", "input=3.14") + @Iteration("y!=x", "answer=y", "input=x") + @Iteration("3.14!=x", "answer=3.14", "input=x") fun testMatches_differentSingleTerms_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -144,16 +137,14 @@ class AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("3.14+1!=1+3.14", "answer=3.14+1", "input=1+3.14"), - Iteration("3+2+1!=1+2+3", "answer=3+2+1", "input=1+2+3"), - Iteration("-3.14+1!=1-3.14", "answer=-3.14+1", "input=1-3.14"), - Iteration("3.14*2!=2*3.14", "answer=3.14*2", "input=2*3.14"), - Iteration("2+x!=x+2", "answer=2+x", "input=x+2"), - Iteration("y+x!=x+y", "answer=y+x", "input=x+y"), - Iteration("x*2!=2x", "answer=x*2", "input=2x"), - Iteration("yx!=xy", "answer=yx", "input=xy") - ) + @Iteration("3.14+1!=1+3.14", "answer=3.14+1", "input=1+3.14") + @Iteration("3+2+1!=1+2+3", "answer=3+2+1", "input=1+2+3") + @Iteration("-3.14+1!=1-3.14", "answer=-3.14+1", "input=1-3.14") + @Iteration("3.14*2!=2*3.14", "answer=3.14*2", "input=2*3.14") + @Iteration("2+x!=x+2", "answer=2+x", "input=x+2") + @Iteration("y+x!=x+y", "answer=y+x", "input=x+y") + @Iteration("x*2!=2x", "answer=x*2", "input=2x") + @Iteration("yx!=xy", "answer=yx", "input=xy") fun testMatches_operationsDiffer_byCommutativity_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -165,14 +156,12 @@ class AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1+(2+3)!=(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3"), - Iteration("2*(3*4)!=(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4"), - Iteration("x+(2+3)!=(x+2)+3", "answer=x+(2+3)", "input=(x+2)+3"), - Iteration("x+(y+z)!=(x+y)+z", "answer=x+(y+z)", "input=(x+y)+z"), - Iteration("2*(3x)!=(2x)*3", "answer=2*(3x)", "input=(2x)*3"), - Iteration("x(yz)!=(xy)z", "answer=x(yz)", "input=(xy)z") - ) + @Iteration("1+(2+3)!=(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3") + @Iteration("2*(3*4)!=(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4") + @Iteration("x+(2+3)!=(x+2)+3", "answer=x+(2+3)", "input=(x+2)+3") + @Iteration("x+(y+z)!=(x+y)+z", "answer=x+(y+z)", "input=(x+y)+z") + @Iteration("2*(3x)!=(2x)*3", "answer=2*(3x)", "input=(2x)*3") + @Iteration("x(yz)!=(xy)z", "answer=x(yz)", "input=(xy)z") fun testMatches_operationsDiffer_byAssociativity_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -184,17 +173,15 @@ class AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14"), - Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3"), - Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14"), - Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4"), - Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14"), - Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14"), - Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z"), - Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14"), - Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") - ) + @Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14") + @Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3") + @Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14") + @Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4") + @Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14") + @Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14") + @Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z") + @Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14") + @Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") fun testMatches_operationsDiffer_byNonCommutativeOrAssociativeReordering_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -207,26 +194,24 @@ class AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1-2!=-(2-1)", "answer=1-2", "input=-(2-1)"), - Iteration("1+2!=1+1+1", "answer=1+2", "input=1+1+1"), - Iteration("1+2!=1-(-2)", "answer=1+2", "input=1-(-2)"), - Iteration("4-6!=1-2-1", "answer=4-6", "input=1-2-1"), - Iteration("2*3*2*2!=2*3*4", "answer=2*3*2*2", "input=2*3*4"), - Iteration("-6-2!=2*-(3+1)", "answer=-6-2", "input=2*-(3+1)"), - Iteration("2/3/2/2!=2/3/4", "answer=2/3/2/2", "input=2/3/4"), - Iteration("2^(2+1)!=2^3", "answer=2^(2+1)", "input=2^3"), - Iteration("2^(-1)!=1/2", "answer=2^(-1)", "input=1/2"), - Iteration("x-y!=-(y-x)", "answer=x-y", "input=-(y-x)"), - Iteration("2+x!=1+x+1", "answer=2+x", "input=1+x+1"), - Iteration("1+x!=1-(-x)", "answer=1+x", "input=1-(-x)"), - Iteration("x!=1-x-1", "answer=x", "input=1-x-1"), - Iteration("4x!=2*2*x", "answer=4x", "input=2*2*x"), - Iteration("2-6x!=2*(-3x+1)", "answer=2-6x", "input=2*(-3x+1)"), - Iteration("x/4!=x/2/2", "answer=x/4", "input=x/2/2"), - Iteration("x^(2+1)!=x^3", "answer=x^(2+1)", "input=x^3"), - Iteration("x*(2^(-1))!=x/2", "answer=x*(2^(-1))", "input=x/2") - ) + @Iteration("1-2!=-(2-1)", "answer=1-2", "input=-(2-1)") + @Iteration("1+2!=1+1+1", "answer=1+2", "input=1+1+1") + @Iteration("1+2!=1-(-2)", "answer=1+2", "input=1-(-2)") + @Iteration("4-6!=1-2-1", "answer=4-6", "input=1-2-1") + @Iteration("2*3*2*2!=2*3*4", "answer=2*3*2*2", "input=2*3*4") + @Iteration("-6-2!=2*-(3+1)", "answer=-6-2", "input=2*-(3+1)") + @Iteration("2/3/2/2!=2/3/4", "answer=2/3/2/2", "input=2/3/4") + @Iteration("2^(2+1)!=2^3", "answer=2^(2+1)", "input=2^3") + @Iteration("2^(-1)!=1/2", "answer=2^(-1)", "input=1/2") + @Iteration("x-y!=-(y-x)", "answer=x-y", "input=-(y-x)") + @Iteration("2+x!=1+x+1", "answer=2+x", "input=1+x+1") + @Iteration("1+x!=1-(-x)", "answer=1+x", "input=1-(-x)") + @Iteration("x!=1-x-1", "answer=x", "input=1-x-1") + @Iteration("4x!=2*2*x", "answer=4x", "input=2*2*x") + @Iteration("2-6x!=2*(-3x+1)", "answer=2-6x", "input=2*(-3x+1)") + @Iteration("x/4!=x/2/2", "answer=x/4", "input=x/2/2") + @Iteration("x^(2+1)!=x^3", "answer=x^(2+1)", "input=x^3") + @Iteration("x*(2^(-1))!=x/2", "answer=x*(2^(-1))", "input=x/2") fun testMatches_operationsDiffer_byDistributionAndCombining_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -238,52 +223,50 @@ class AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration( - "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", - "answer=2 * (50 + 150 + 100 + 25) ", - "input=2 × (50 + 150 + 100 + 25)" - ), - Iteration("5+2==5+2", "answer=5+2", "input=5+2"), - Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)"), - Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)"), - Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5"), - Iteration( - "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration("4x^2+20x==4*x^2+20x", "answer=4x^2+20x", "input=4*x^2+20x"), - Iteration("3+x-5==3+x-5", "answer=3+x-5", "input=3+x-5"), - Iteration("Z+A-Z==Z+A-Z", "answer=Z+A-Z", "input=Z+A-Z"), - Iteration("6C - 5A -1==6C - 5A -1", "answer=6C - 5A -1", "input=6C - 5A -1"), - Iteration("5Z-w==5*Z-w", "answer=5Z-w", "input=5*Z-w"), - Iteration("5*Z-w==5*Z-w", "answer=5*Z-w", "input=5*Z-w"), - Iteration("LS-3S+L==L*S-3S+L", "answer=LS-3S+L", "input=L*S-3S+L"), - Iteration("L*S-3S+L==L*S-3S+L", "answer=L*S-3S+L", "input=L*S-3S+L"), - Iteration("L*S-3*S+L==L*S-3S+L", "answer=L*S-3*S+L", "input=L*S-3S+L"), - Iteration("LS-3*S+L==L*S-3S+L", "answer=LS-3*S+L", "input=L*S-3S+L"), - Iteration("9x^2 − 6x + 1==9x^2 − 6x + 1", "answer=9x^2 − 6x + 1", "input=9x^2 − 6x + 1"), - Iteration("c*b-c==c*b-c", "answer=c*b-c", "input=c*b-c"), - Iteration("cb-c==c*b-c", "answer=cb-c", "input=c*b-c"), - Iteration("x^2+y+4x==x^2+y+4x", "answer=x^2+y+4x", "input=x^2+y+4x"), - Iteration("Y+5==Y+5", "answer=Y+5", "input=Y+5"), - Iteration( - "a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(x^2 − x)/3 − 4y==(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration("(3x -1)^2==(3x-1)^2", "answer=(3x -1)^2", "input=(3x-1)^2") + @Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration( + "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" ) + @Iteration( + "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", + "answer=2 * (50 + 150 + 100 + 25) ", + "input=2 × (50 + 150 + 100 + 25)" + ) + @Iteration("5+2==5+2", "answer=5+2", "input=5+2") + @Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)") + @Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)") + @Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5") + @Iteration( + "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("4x^2+20x==4*x^2+20x", "answer=4x^2+20x", "input=4*x^2+20x") + @Iteration("3+x-5==3+x-5", "answer=3+x-5", "input=3+x-5") + @Iteration("Z+A-Z==Z+A-Z", "answer=Z+A-Z", "input=Z+A-Z") + @Iteration("6C - 5A -1==6C - 5A -1", "answer=6C - 5A -1", "input=6C - 5A -1") + @Iteration("5Z-w==5*Z-w", "answer=5Z-w", "input=5*Z-w") + @Iteration("5*Z-w==5*Z-w", "answer=5*Z-w", "input=5*Z-w") + @Iteration("LS-3S+L==L*S-3S+L", "answer=LS-3S+L", "input=L*S-3S+L") + @Iteration("L*S-3S+L==L*S-3S+L", "answer=L*S-3S+L", "input=L*S-3S+L") + @Iteration("L*S-3*S+L==L*S-3S+L", "answer=L*S-3*S+L", "input=L*S-3S+L") + @Iteration("LS-3*S+L==L*S-3S+L", "answer=LS-3*S+L", "input=L*S-3S+L") + @Iteration("9x^2 − 6x + 1==9x^2 − 6x + 1", "answer=9x^2 − 6x + 1", "input=9x^2 − 6x + 1") + @Iteration("c*b-c==c*b-c", "answer=c*b-c", "input=c*b-c") + @Iteration("cb-c==c*b-c", "answer=cb-c", "input=c*b-c") + @Iteration("x^2+y+4x==x^2+y+4x", "answer=x^2+y+4x", "input=x^2+y+4x") + @Iteration("Y+5==Y+5", "answer=Y+5", "input=Y+5") + @Iteration( + "a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(x^2 − x)/3 − 4y==(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration("(3x -1)^2==(3x-1)^2", "answer=(3x -1)^2", "input=(3x-1)^2") fun testMatches_assortedExpressions_withMatchingCharacteristics_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -296,284 +279,282 @@ class AlgebraicExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration( - "2 × (50 + 150 + 100 + 25) ==(50 + 150 + 100 + 25) × 2", - "answer=2 × (50 + 150 + 100 + 25) ", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration("2+5!=5+2", "answer=2+5", "input=5+2"), - Iteration("− (− 4) + 6!=6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)"), - Iteration("10!=6 − (− 4)", "answer=10", "input=6 − (− 4)"), - Iteration("6 + 4!=6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)"), - Iteration("6 + 2^2!=6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)"), - Iteration("3 * 2 − (− 4)!=6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)"), - Iteration("100/10!=6 − (− 4)", "answer=100/10", "input=6 − (− 4)"), - Iteration("3/(10 * 10^4)!=3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5"), - Iteration( - "200 + 30 + 4 + 0.5 + 0.06 + 1000!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "0.06 + 0.5 + 4 + 30 + 200 + 1000!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1234.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "123456/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456/100", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "61728/50!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=61728/50", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1234 + 56/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234 + 56/100", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1230 + 4.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1230 + 4.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "2 * 2 * 3 * 3 * 1!=2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" - ), - Iteration("2 * 2 * 9!=2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3"), - Iteration("4 * 3^2!=2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3"), - Iteration("8/2 * 3 * 3!=2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration("36!=2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3"), - Iteration("sqrt(4-2)!=sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)"), - Iteration("bc-c!=c*b-c", "answer=bc-c", "input=c*b-c"), - Iteration("-c+bc!=c*b-c", "answer=-c+bc", "input=c*b-c"), - Iteration("-c+cb!=c*b-c", "answer=-c+cb", "input=c*b-c"), - Iteration("y+4x+x^2!=x^2+y+4x", "answer=y+4x+x^2", "input=x^2+y+4x"), - Iteration("x^2+4x+y!=x^2+y+4x", "answer=x^2+4x+y", "input=x^2+y+4x"), - Iteration("5+Y!=Y+5", "answer=5+Y", "input=Y+5"), - Iteration( - "a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "2a*b + 2bc + 2a*c + a^2 + b^2 + c^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=2a*b + 2bc + 2a*c + a^2 + b^2 + c^2", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(a+ b)^2 + c^2 + 2bc + 2a*c!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(a+ b)^2 + c^2 + 2bc + 2a*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(a+b+c)^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", "answer=(a+b+c)^2", "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(-a -b -c)^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(-a -b -c)^2", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration("1 - 6x + 9x^2!=9x^2 − 6x + 1", "answer=1 - 6x + 9x^2", "input=9x^2 − 6x + 1"), - Iteration("9x^2 + 1 - 6x!=9x^2 − 6x + 1", "answer=9x^2 + 1 - 6x", "input=9x^2 − 6x + 1"), - Iteration("2+1+x!=x+1+2", "answer=2+1+x", "input=x+1+2"), - Iteration("1+2+x!=x+1+2", "answer=1+2+x", "input=x+1+2"), - Iteration("1+x+2!=x+1+2", "answer=1+x+2", "input=x+1+2"), - Iteration("2+x+1!=x+1+2", "answer=2+x+1", "input=x+1+2"), - Iteration("(x+1)+2!=x+1+2", "answer=(x+1)+2", "input=x+1+2"), - Iteration("x + (1+2)!=x+1+2", "answer=x + (1+2)", "input=x+1+2"), - Iteration( - "y+1+ 9x(x − 6)!=9x(x − 6) + 1+ y", "answer=y+1+ 9x(x − 6)", "input=9x(x − 6) + 1+ y" - ), - Iteration("1+y+9x(x − 6)!=9x(x − 6) + 1+ y", "answer=1+y+9x(x − 6)", "input=9x(x − 6) + 1+ y"), - Iteration( - "1 + 9x(x − 6) + y!=9x(x − 6) + 1+ y", "answer=1 + 9x(x − 6) + y", "input=9x(x − 6) + 1+ y" - ), - Iteration( - "(y+1)+9x(x − 6)!=9x(x − 6) + 1+ y", "answer=(y+1)+9x(x − 6)", "input=9x(x − 6) + 1+ y" - ), - Iteration( - "-4y + (x^2 − x)/3!=(x^2 − x)/3 − 4y", "answer=-4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "x(x − 1)/3 −4y!=(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 −4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "x^2/3 − x/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x^2/3 − x/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "x^2/3 − (x/3 + 4y)!=(x^2 − x)/3 − 4y", "answer=x^2/3 − (x/3 + 4y)", "input=(x^2 − x)/3 − 4y" - ), - Iteration("√(3x −1)4!=(3x-1)^2", "answer=√(3x −1)4", "input=(3x-1)^2"), - Iteration("3x(3x - 2) + 1!=(3x-1)^2", "answer=3x(3x - 2) + 1", "input=(3x-1)^2"), - Iteration("3(3x^2) - 6x +1!=(3x-1)^2", "answer=3(3x^2) - 6x +1", "input=(3x-1)^2"), - Iteration("2x!=sqrt(4x^2)", "answer=2x", "input=sqrt(4x^2)"), - Iteration("x^2+2x+1!=(x+1)^2", "answer=x^2+2x+1", "input=(x+1)^2"), - Iteration("x^2-1!=(x+1)(x-1)", "answer=x^2-1", "input=(x+1)(x-1)"), - Iteration("x+1!=(x^2+2x+1)/(x+1)", "answer=x+1", "input=(x^2+2x+1)/(x+1)"), - Iteration("x-1!=(x^2-1)/(x+1)", "answer=x-1", "input=(x^2-1)/(x+1)"), - Iteration("x+1!=(x^2-1)/(x-1)", "answer=x+1", "input=(x^2-1)/(x-1)"), - Iteration("-3x!=(-27x^3)^(1/3)", "answer=-3x", "input=(-27x^3)^(1/3)"), - Iteration("1!=(x^2-1)/(x^2-1)", "answer=1", "input=(x^2-1)/(x^2-1)"), - Iteration("2*(6+3+4) + 4!=2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)"), - Iteration("2*(2+6+3) + 8!=2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)"), - Iteration("(2+6+3+4)*2!=2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)"), - Iteration("(2+6+3+4) × 2!=2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)"), - Iteration("15 - 12 + 3!=15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3"), - Iteration( - "3 - (6 * 2) + 15!=15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" - ), - Iteration( - "15 - (2 × 6) + 3!=15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2 *(50 + 150) + 2*(100 + 25)!=(50 + 150 + 100 + 25) × 2", - "answer=2 *(50 + 150) + 2*(100 + 25)", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration( - "2* ( 25+50+100+150)!=(50 + 150 + 100 + 25) × 2", - "answer=2* ( 25+50+100+150)", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration("10^−5 * 3!=3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5"), - Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5"), - Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5"), - Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5"), - Iteration("30 * 10^−6!=3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5"), - Iteration("0.00003!=3 * 10^-5", "answer=0.00003", "input=3 * 10^-5"), - Iteration("3/10^5!=3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5"), - Iteration( - "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("3 *2 – (− 4)!=6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)"), - Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)"), - Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)"), - Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)"), - Iteration("7!=5+2", "answer=7", "input=5+2"), - Iteration("3+4!=5+2", "answer=3+4", "input=5+2"), - Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3"), - Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration("20x+4x^2!=4*x^2+20x", "answer=20x+4x^2", "input=4*x^2+20x"), - Iteration("x-5+3!=3+x-5", "answer=x-5+3", "input=3+x-5"), - Iteration("-5+3+x!=3+x-5", "answer=-5+3+x", "input=3+x-5"), - Iteration("-5+x+3!=3+x-5", "answer=-5+x+3", "input=3+x-5"), - Iteration("3+(x-5)!=3+x-5", "answer=3+(x-5)", "input=3+x-5"), - Iteration("A!=Z+A-Z", "answer=A", "input=Z+A-Z"), - Iteration("A+Z-Z!=Z+A-Z", "answer=A+Z-Z", "input=Z+A-Z"), - Iteration("Z+(A-Z)!=Z+A-Z", "answer=Z+(A-Z)", "input=Z+A-Z"), - Iteration("6C - (5A+1)!=6C - 5A -1", "answer=6C - (5A+1)", "input=6C - 5A -1"), - Iteration("-5A-1+6C!=6C - 5A -1", "answer=-5A-1+6C", "input=6C - 5A -1"), - Iteration("-W+5Z!=5*Z-W", "answer=-W+5Z", "input=5*Z-W"), - Iteration("L(1+S)-3S!=L*S-3S+L", "answer=L(1+S)-3S", "input=L*S-3S+L"), - Iteration("S(L-3)+L!=L*S-3S+L", "answer=S(L-3)+L", "input=L*S-3S+L"), - Iteration("L+LS-3S!=L*S-3S+L", "answer=L+LS-3S", "input=L*S-3S+L"), - Iteration( - "x(x − 1)/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "- 4y + (x^2 − x)/3!=(x^2 − x)/3 − 4y", "answer=- 4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 − x) * 3^-1 − 4y!=(x^2 − x)/3 − 4y", - "answer=(x^2 − x) * 3^-1 − 4y", - "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "x(x^2 − x)/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 − x)/3 + 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 + 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 + x)/3 - 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 + x)/3 - 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 − x)*0.33 - 4y!=(x^2 − x)/3 − 4y", - "answer=(x^2 − x)*0.33 - 4y", - "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "a^2 + b^2 + c^2 + 2(a*b + a*c + bc)!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2 + 2(a*b + a*c + bc)", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(a + b)^2 + c^2 + 2a*c + 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(a + b)^2 + c^2 + 2a*c + 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(a + b + c)^3!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(a + b + c)^3", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a^2 + b^2 + c^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration("(3x − 1)^2!=9x^2 − 6x + 1", "answer=(3x − 1)^2", "input=9x^2 − 6x + 1"), - Iteration("3x(3x − 2) + 1!=9x^2 − 6x + 1", "answer=3x(3x − 2) + 1", "input=9x^2 − 6x + 1"), - Iteration("3(3x^2 − 2x) + 1!=9x^2 − 6x + 1", "answer=3(3x^2 − 2x) + 1", "input=9x^2 − 6x + 1"), - Iteration("(3x)^2 − 6x + 1!=9x^2 − 6x + 1", "answer=(3x)^2 − 6x + 1", "input=9x^2 − 6x + 1"), - Iteration("c(b-1)!=c*b-c", "answer=c(b-1)", "input=c*b-c"), - Iteration("x(x+4)+y!=x^2+y+4x", "answer=x(x+4)+y", "input=x^2+y+4x"), - Iteration("Y!=Y+5", "answer=Y", "input=Y+5"), - Iteration("5!=Y+5", "answer=5", "input=Y+5"), - Iteration("x+3!=x+1+2", "answer=x+3", "input=x+1+2"), - Iteration("(1 - 3x)^2!=(3x-1)^2", "answer=(1 - 3x)^2", "input=(3x-1)^2"), - Iteration("9x^2 - 6x - 1!=(3x-1)^2", "answer=9x^2 - 6x - 1", "input=(3x-1)^2"), - Iteration("(3x −1)!=(3x-1)^2", "answer=(3x −1)", "input=(3x-1)^2"), - Iteration("2x!=sqrt(2x)^2", "answer=2x", "input=sqrt(2x)^2"), - Iteration("2x!=sqrt(-4x^2)", "answer=2x", "input=sqrt(-4x^2)"), - Iteration("x^2+2x+1!=(x+2)^2", "answer=x^2+2x+1", "input=(x+2)^2"), - Iteration("x^2-1!=(x+1)(1-x)", "answer=x^2-1", "input=(x+1)(1-x)"), - Iteration("x+1!=(x^2+2x+1)/(x-1)", "answer=x+1", "input=(x^2+2x+1)/(x-1)"), - Iteration("x-1!=(x^2-1)/x", "answer=x-1", "input=(x^2-1)/x"), - Iteration("x+1!=(x^2-1)/(x-2)", "answer=x+1", "input=(x^2-1)/(x-2)"), - Iteration("-3x!=(9x^3)^(1/3)", "answer=-3x", "input=(9x^3)^(1/3)") + @Iteration( + "2 × (50 + 150 + 100 + 25) ==(50 + 150 + 100 + 25) × 2", + "answer=2 × (50 + 150 + 100 + 25) ", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration("2+5!=5+2", "answer=2+5", "input=5+2") + @Iteration("− (− 4) + 6!=6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)") + @Iteration("10!=6 − (− 4)", "answer=10", "input=6 − (− 4)") + @Iteration("6 + 4!=6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)") + @Iteration("6 + 2^2!=6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)") + @Iteration("3 * 2 − (− 4)!=6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)") + @Iteration("100/10!=6 − (− 4)", "answer=100/10", "input=6 − (− 4)") + @Iteration("3/(10 * 10^4)!=3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5") + @Iteration( + "200 + 30 + 4 + 0.5 + 0.06 + 1000!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "0.06 + 0.5 + 4 + 30 + 200 + 1000!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1234.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "123456/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456/100", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "61728/50!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=61728/50", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1234 + 56/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234 + 56/100", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1230 + 4.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1230 + 4.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "2 * 2 * 3 * 3 * 1!=2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" + ) + @Iteration("2 * 2 * 9!=2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3") + @Iteration("4 * 3^2!=2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3") + @Iteration("8/2 * 3 * 3!=2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("36!=2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3") + @Iteration("sqrt(4-2)!=sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)") + @Iteration("bc-c!=c*b-c", "answer=bc-c", "input=c*b-c") + @Iteration("-c+bc!=c*b-c", "answer=-c+bc", "input=c*b-c") + @Iteration("-c+cb!=c*b-c", "answer=-c+cb", "input=c*b-c") + @Iteration("y+4x+x^2!=x^2+y+4x", "answer=y+4x+x^2", "input=x^2+y+4x") + @Iteration("x^2+4x+y!=x^2+y+4x", "answer=x^2+4x+y", "input=x^2+y+4x") + @Iteration("5+Y!=Y+5", "answer=5+Y", "input=Y+5") + @Iteration( + "a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "2a*b + 2bc + 2a*c + a^2 + b^2 + c^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=2a*b + 2bc + 2a*c + a^2 + b^2 + c^2", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(a+ b)^2 + c^2 + 2bc + 2a*c!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(a+ b)^2 + c^2 + 2bc + 2a*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(a+b+c)^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", "answer=(a+b+c)^2", "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(-a -b -c)^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(-a -b -c)^2", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration("1 - 6x + 9x^2!=9x^2 − 6x + 1", "answer=1 - 6x + 9x^2", "input=9x^2 − 6x + 1") + @Iteration("9x^2 + 1 - 6x!=9x^2 − 6x + 1", "answer=9x^2 + 1 - 6x", "input=9x^2 − 6x + 1") + @Iteration("2+1+x!=x+1+2", "answer=2+1+x", "input=x+1+2") + @Iteration("1+2+x!=x+1+2", "answer=1+2+x", "input=x+1+2") + @Iteration("1+x+2!=x+1+2", "answer=1+x+2", "input=x+1+2") + @Iteration("2+x+1!=x+1+2", "answer=2+x+1", "input=x+1+2") + @Iteration("(x+1)+2!=x+1+2", "answer=(x+1)+2", "input=x+1+2") + @Iteration("x + (1+2)!=x+1+2", "answer=x + (1+2)", "input=x+1+2") + @Iteration( + "y+1+ 9x(x − 6)!=9x(x − 6) + 1+ y", "answer=y+1+ 9x(x − 6)", "input=9x(x − 6) + 1+ y" + ) + @Iteration("1+y+9x(x − 6)!=9x(x − 6) + 1+ y", "answer=1+y+9x(x − 6)", "input=9x(x − 6) + 1+ y") + @Iteration( + "1 + 9x(x − 6) + y!=9x(x − 6) + 1+ y", "answer=1 + 9x(x − 6) + y", "input=9x(x − 6) + 1+ y" + ) + @Iteration( + "(y+1)+9x(x − 6)!=9x(x − 6) + 1+ y", "answer=(y+1)+9x(x − 6)", "input=9x(x − 6) + 1+ y" + ) + @Iteration( + "-4y + (x^2 − x)/3!=(x^2 − x)/3 − 4y", "answer=-4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "x(x − 1)/3 −4y!=(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 −4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "x^2/3 − x/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x^2/3 − x/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "x^2/3 − (x/3 + 4y)!=(x^2 − x)/3 − 4y", "answer=x^2/3 − (x/3 + 4y)", "input=(x^2 − x)/3 − 4y" + ) + @Iteration("√(3x −1)4!=(3x-1)^2", "answer=√(3x −1)4", "input=(3x-1)^2") + @Iteration("3x(3x - 2) + 1!=(3x-1)^2", "answer=3x(3x - 2) + 1", "input=(3x-1)^2") + @Iteration("3(3x^2) - 6x +1!=(3x-1)^2", "answer=3(3x^2) - 6x +1", "input=(3x-1)^2") + @Iteration("2x!=sqrt(4x^2)", "answer=2x", "input=sqrt(4x^2)") + @Iteration("x^2+2x+1!=(x+1)^2", "answer=x^2+2x+1", "input=(x+1)^2") + @Iteration("x^2-1!=(x+1)(x-1)", "answer=x^2-1", "input=(x+1)(x-1)") + @Iteration("x+1!=(x^2+2x+1)/(x+1)", "answer=x+1", "input=(x^2+2x+1)/(x+1)") + @Iteration("x-1!=(x^2-1)/(x+1)", "answer=x-1", "input=(x^2-1)/(x+1)") + @Iteration("x+1!=(x^2-1)/(x-1)", "answer=x+1", "input=(x^2-1)/(x-1)") + @Iteration("-3x!=(-27x^3)^(1/3)", "answer=-3x", "input=(-27x^3)^(1/3)") + @Iteration("1!=(x^2-1)/(x^2-1)", "answer=1", "input=(x^2-1)/(x^2-1)") + @Iteration("2*(6+3+4) + 4!=2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)") + @Iteration("2*(2+6+3) + 8!=2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)") + @Iteration("(2+6+3+4)*2!=2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)") + @Iteration("(2+6+3+4) × 2!=2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)") + @Iteration("15 - 12 + 3!=15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3") + @Iteration( + "3 - (6 * 2) + 15!=15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "15 - (2 × 6) + 3!=15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "2 *(50 + 150) + 2*(100 + 25)!=(50 + 150 + 100 + 25) × 2", + "answer=2 *(50 + 150) + 2*(100 + 25)", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration( + "2* ( 25+50+100+150)!=(50 + 150 + 100 + 25) × 2", + "answer=2* ( 25+50+100+150)", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration("10^−5 * 3!=3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5") + @Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5") + @Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5") + @Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5") + @Iteration("30 * 10^−6!=3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5") + @Iteration("0.00003!=3 * 10^-5", "answer=0.00003", "input=3 * 10^-5") + @Iteration("3/10^5!=3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5") + @Iteration( + "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration("3 *2 – (− 4)!=6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)") + @Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)") + @Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)") + @Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)") + @Iteration("7!=5+2", "answer=7", "input=5+2") + @Iteration("3+4!=5+2", "answer=3+4", "input=5+2") + @Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3") + @Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("20x+4x^2!=4*x^2+20x", "answer=20x+4x^2", "input=4*x^2+20x") + @Iteration("x-5+3!=3+x-5", "answer=x-5+3", "input=3+x-5") + @Iteration("-5+3+x!=3+x-5", "answer=-5+3+x", "input=3+x-5") + @Iteration("-5+x+3!=3+x-5", "answer=-5+x+3", "input=3+x-5") + @Iteration("3+(x-5)!=3+x-5", "answer=3+(x-5)", "input=3+x-5") + @Iteration("A!=Z+A-Z", "answer=A", "input=Z+A-Z") + @Iteration("A+Z-Z!=Z+A-Z", "answer=A+Z-Z", "input=Z+A-Z") + @Iteration("Z+(A-Z)!=Z+A-Z", "answer=Z+(A-Z)", "input=Z+A-Z") + @Iteration("6C - (5A+1)!=6C - 5A -1", "answer=6C - (5A+1)", "input=6C - 5A -1") + @Iteration("-5A-1+6C!=6C - 5A -1", "answer=-5A-1+6C", "input=6C - 5A -1") + @Iteration("-W+5Z!=5*Z-W", "answer=-W+5Z", "input=5*Z-W") + @Iteration("L(1+S)-3S!=L*S-3S+L", "answer=L(1+S)-3S", "input=L*S-3S+L") + @Iteration("S(L-3)+L!=L*S-3S+L", "answer=S(L-3)+L", "input=L*S-3S+L") + @Iteration("L+LS-3S!=L*S-3S+L", "answer=L+LS-3S", "input=L*S-3S+L") + @Iteration( + "x(x − 1)/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "- 4y + (x^2 − x)/3!=(x^2 − x)/3 − 4y", "answer=- 4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 − x) * 3^-1 − 4y!=(x^2 − x)/3 − 4y", + "answer=(x^2 − x) * 3^-1 − 4y", + "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "x(x^2 − x)/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 − x)/3 + 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 + 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 + x)/3 - 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 + x)/3 - 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 − x)*0.33 - 4y!=(x^2 − x)/3 − 4y", + "answer=(x^2 − x)*0.33 - 4y", + "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "a^2 + b^2 + c^2 + 2(a*b + a*c + bc)!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2 + 2(a*b + a*c + bc)", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(a + b)^2 + c^2 + 2a*c + 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(a + b)^2 + c^2 + 2a*c + 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(a + b + c)^3!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(a + b + c)^3", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a^2 + b^2 + c^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" ) + @Iteration("(3x − 1)^2!=9x^2 − 6x + 1", "answer=(3x − 1)^2", "input=9x^2 − 6x + 1") + @Iteration("3x(3x − 2) + 1!=9x^2 − 6x + 1", "answer=3x(3x − 2) + 1", "input=9x^2 − 6x + 1") + @Iteration("3(3x^2 − 2x) + 1!=9x^2 − 6x + 1", "answer=3(3x^2 − 2x) + 1", "input=9x^2 − 6x + 1") + @Iteration("(3x)^2 − 6x + 1!=9x^2 − 6x + 1", "answer=(3x)^2 − 6x + 1", "input=9x^2 − 6x + 1") + @Iteration("c(b-1)!=c*b-c", "answer=c(b-1)", "input=c*b-c") + @Iteration("x(x+4)+y!=x^2+y+4x", "answer=x(x+4)+y", "input=x^2+y+4x") + @Iteration("Y!=Y+5", "answer=Y", "input=Y+5") + @Iteration("5!=Y+5", "answer=5", "input=Y+5") + @Iteration("x+3!=x+1+2", "answer=x+3", "input=x+1+2") + @Iteration("(1 - 3x)^2!=(3x-1)^2", "answer=(1 - 3x)^2", "input=(3x-1)^2") + @Iteration("9x^2 - 6x - 1!=(3x-1)^2", "answer=9x^2 - 6x - 1", "input=(3x-1)^2") + @Iteration("(3x −1)!=(3x-1)^2", "answer=(3x −1)", "input=(3x-1)^2") + @Iteration("2x!=sqrt(2x)^2", "answer=2x", "input=sqrt(2x)^2") + @Iteration("2x!=sqrt(-4x^2)", "answer=2x", "input=sqrt(-4x^2)") + @Iteration("x^2+2x+1!=(x+2)^2", "answer=x^2+2x+1", "input=(x+2)^2") + @Iteration("x^2-1!=(x+1)(1-x)", "answer=x^2-1", "input=(x+1)(1-x)") + @Iteration("x+1!=(x^2+2x+1)/(x-1)", "answer=x+1", "input=(x^2+2x+1)/(x-1)") + @Iteration("x-1!=(x^2-1)/x", "answer=x-1", "input=(x^2-1)/x") + @Iteration("x+1!=(x^2-1)/(x-2)", "answer=x+1", "input=(x^2-1)/(x-2)") + @Iteration("-3x!=(9x^3)^(1/3)", "answer=-3x", "input=(9x^3)^(1/3)") fun testMatches_assortedExpressions_withoutMatchingCharacteristics_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt index 22e3f4b749f..5b711d3b879 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/algebraicexpressioninput/AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt @@ -19,7 +19,6 @@ import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -76,13 +75,11 @@ class AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvi } @Test - @RunParameterized( - Iteration("0==0", "answer=0", "input=0"), - Iteration("1==1", "answer=1", "input=1"), - Iteration("2==2", "answer=2", "input=2"), - Iteration("x==x", "answer=x", "input=x"), - Iteration("y==y", "answer=y", "input=y") - ) + @Iteration("0==0", "answer=0", "input=0") + @Iteration("1==1", "answer=1", "input=1") + @Iteration("2==2", "answer=2", "input=2") + @Iteration("x==x", "answer=x", "input=x") + @Iteration("y==y", "answer=y", "input=y") fun testMatches_sameSingleTerms_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -94,25 +91,23 @@ class AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvi } @Test - @RunParameterized( - Iteration("-2==-2", "answer=-2", "input=-2"), - Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14"), - Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14"), - Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3"), - Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14"), - Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14"), - Iteration("2/3==2/3", "answer=2/3", "input=2/3"), - Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14"), - Iteration("2^3==2^3", "answer=2^3", "input=2^3"), - Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14"), - Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)"), - Iteration("-x==-x", "answer=-x", "input=-x"), - Iteration("x+3.14==x+3.14", "answer=x+3.14", "input=x+3.14"), - Iteration("x-3.14==x-3.14", "answer=x-3.14", "input=x-3.14"), - Iteration("x*3.14==x*3.14", "answer=x*3.14", "input=x*3.14"), - Iteration("x/3==x/3", "answer=x/3", "input=x/3"), - Iteration("sqrt(x)==sqrt(x)", "answer=sqrt(x)", "input=sqrt(x)") - ) + @Iteration("-2==-2", "answer=-2", "input=-2") + @Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14") + @Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14") + @Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3") + @Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14") + @Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14") + @Iteration("2/3==2/3", "answer=2/3", "input=2/3") + @Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14") + @Iteration("2^3==2^3", "answer=2^3", "input=2^3") + @Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14") + @Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)") + @Iteration("-x==-x", "answer=-x", "input=-x") + @Iteration("x+3.14==x+3.14", "answer=x+3.14", "input=x+3.14") + @Iteration("x-3.14==x-3.14", "answer=x-3.14", "input=x-3.14") + @Iteration("x*3.14==x*3.14", "answer=x*3.14", "input=x*3.14") + @Iteration("x/3==x/3", "answer=x/3", "input=x/3") + @Iteration("sqrt(x)==sqrt(x)", "answer=sqrt(x)", "input=sqrt(x)") fun testMatches_sameSingleOperations_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -124,15 +119,13 @@ class AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvi } @Test - @RunParameterized( - Iteration("1!=0", "answer=1", "input=0"), - Iteration("0!=1", "answer=0", "input=1"), - Iteration("3.14!=1", "answer=3.14", "input=1"), - Iteration("1!=3.14", "answer=1", "input=3.14"), - Iteration("x!=3.14", "answer=x", "input=3.14"), - Iteration("y!=x", "answer=y", "input=x"), - Iteration("3.14!=x", "answer=3.14", "input=x") - ) + @Iteration("1!=0", "answer=1", "input=0") + @Iteration("0!=1", "answer=0", "input=1") + @Iteration("3.14!=1", "answer=3.14", "input=1") + @Iteration("1!=3.14", "answer=1", "input=3.14") + @Iteration("x!=3.14", "answer=x", "input=3.14") + @Iteration("y!=x", "answer=y", "input=x") + @Iteration("3.14!=x", "answer=3.14", "input=x") fun testMatches_differentSingleTerms_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -145,16 +138,14 @@ class AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvi } @Test - @RunParameterized( - Iteration("3.14+1==1+3.14", "answer=3.14+1", "input=1+3.14"), - Iteration("3+2+1==1+2+3", "answer=3+2+1", "input=1+2+3"), - Iteration("-3.14+1==1-3.14", "answer=-3.14+1", "input=1-3.14"), - Iteration("3.14*2==2*3.14", "answer=3.14*2", "input=2*3.14"), - Iteration("2+x==x+2", "answer=2+x", "input=x+2"), - Iteration("y+x==x+y", "answer=y+x", "input=x+y"), - Iteration("x*2==2x", "answer=x*2", "input=2x"), - Iteration("yx==xy", "answer=yx", "input=xy") - ) + @Iteration("3.14+1==1+3.14", "answer=3.14+1", "input=1+3.14") + @Iteration("3+2+1==1+2+3", "answer=3+2+1", "input=1+2+3") + @Iteration("-3.14+1==1-3.14", "answer=-3.14+1", "input=1-3.14") + @Iteration("3.14*2==2*3.14", "answer=3.14*2", "input=2*3.14") + @Iteration("2+x==x+2", "answer=2+x", "input=x+2") + @Iteration("y+x==x+y", "answer=y+x", "input=x+y") + @Iteration("x*2==2x", "answer=x*2", "input=2x") + @Iteration("yx==xy", "answer=yx", "input=xy") fun testMatches_operationsDiffer_byCommutativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -166,14 +157,12 @@ class AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvi } @Test - @RunParameterized( - Iteration("1+(2+3)==(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3"), - Iteration("2*(3*4)==(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4"), - Iteration("x+(2+3)==(x+2)+3", "answer=x+(2+3)", "input=(x+2)+3"), - Iteration("x+(y+z)==(x+y)+z", "answer=x+(y+z)", "input=(x+y)+z"), - Iteration("2*(3x)==(2x)*3", "answer=2*(3x)", "input=(2x)*3"), - Iteration("x(yz)==(xy)z", "answer=x(yz)", "input=(xy)z") - ) + @Iteration("1+(2+3)==(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3") + @Iteration("2*(3*4)==(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4") + @Iteration("x+(2+3)==(x+2)+3", "answer=x+(2+3)", "input=(x+2)+3") + @Iteration("x+(y+z)==(x+y)+z", "answer=x+(y+z)", "input=(x+y)+z") + @Iteration("2*(3x)==(2x)*3", "answer=2*(3x)", "input=(2x)*3") + @Iteration("x(yz)==(xy)z", "answer=x(yz)", "input=(xy)z") fun testMatches_operationsDiffer_byAssociativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -185,17 +174,15 @@ class AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvi } @Test - @RunParameterized( - Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14"), - Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3"), - Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14"), - Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4"), - Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14"), - Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14"), - Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z"), - Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14"), - Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") - ) + @Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14") + @Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3") + @Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14") + @Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4") + @Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14") + @Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14") + @Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z") + @Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14") + @Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") fun testMatches_operationsDiffer_byNonCommutativeOrAssociativeReordering_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -208,10 +195,8 @@ class AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvi } @Test - @RunParameterized( - Iteration("1+2==1-(-2)", "answer=1+2", "input=1-(-2)"), - Iteration("1+x==1-(-x)", "answer=1+x", "input=1-(-x)") - ) + @Iteration("1+2==1-(-2)", "answer=1+2", "input=1-(-2)") + @Iteration("1+x==1-(-x)", "answer=1+x", "input=1-(-x)") fun testMatches_operationsDiffer_byDistributingNegation_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -223,24 +208,22 @@ class AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvi } @Test - @RunParameterized( - Iteration("x-y==-(y-x)", "answer=x-y", "input=-(y-x)"), - Iteration("1-2!=-(2-1)", "answer=1-2", "input=-(2-1)"), - Iteration("1+2!=1+1+1", "answer=1+2", "input=1+1+1"), - Iteration("4-6!=1-2-1", "answer=4-6", "input=1-2-1"), - Iteration("2*3*2*2!=2*3*4", "answer=2*3*2*2", "input=2*3*4"), - Iteration("-6-2!=2*-(3+1)", "answer=-6-2", "input=2*-(3+1)"), - Iteration("2/3/2/2!=2/3/4", "answer=2/3/2/2", "input=2/3/4"), - Iteration("2^(2+1)!=2^3", "answer=2^(2+1)", "input=2^3"), - Iteration("2^(-1)!=1/2", "answer=2^(-1)", "input=1/2"), - Iteration("2+x!=1+x+1", "answer=2+x", "input=1+x+1"), - Iteration("x!=1-x-1", "answer=x", "input=1-x-1"), - Iteration("4x!=2*2*x", "answer=4x", "input=2*2*x"), - Iteration("2-6x!=2*(-3x+1)", "answer=2-6x", "input=2*(-3x+1)"), - Iteration("x/4!=x/2/2", "answer=x/4", "input=x/2/2"), - Iteration("x^(2+1)!=x^3", "answer=x^(2+1)", "input=x^3"), - Iteration("x*(2^(-1))!=x/2", "answer=x*(2^(-1))", "input=x/2") - ) + @Iteration("x-y==-(y-x)", "answer=x-y", "input=-(y-x)") + @Iteration("1-2!=-(2-1)", "answer=1-2", "input=-(2-1)") + @Iteration("1+2!=1+1+1", "answer=1+2", "input=1+1+1") + @Iteration("4-6!=1-2-1", "answer=4-6", "input=1-2-1") + @Iteration("2*3*2*2!=2*3*4", "answer=2*3*2*2", "input=2*3*4") + @Iteration("-6-2!=2*-(3+1)", "answer=-6-2", "input=2*-(3+1)") + @Iteration("2/3/2/2!=2/3/4", "answer=2/3/2/2", "input=2/3/4") + @Iteration("2^(2+1)!=2^3", "answer=2^(2+1)", "input=2^3") + @Iteration("2^(-1)!=1/2", "answer=2^(-1)", "input=1/2") + @Iteration("2+x!=1+x+1", "answer=2+x", "input=1+x+1") + @Iteration("x!=1-x-1", "answer=x", "input=1-x-1") + @Iteration("4x!=2*2*x", "answer=4x", "input=2*2*x") + @Iteration("2-6x!=2*(-3x+1)", "answer=2-6x", "input=2*(-3x+1)") + @Iteration("x/4!=x/2/2", "answer=x/4", "input=x/2/2") + @Iteration("x^(2+1)!=x^3", "answer=x^(2+1)", "input=x^3") + @Iteration("x*(2^(-1))!=x/2", "answer=x*(2^(-1))", "input=x/2") fun testMatches_operationsDiffer_byDistributionAndCombining_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -252,144 +235,142 @@ class AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvi } @Test - @RunParameterized( - Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration( - "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2 × (50 + 150 + 100 + 25) ==(50 + 150 + 100 + 25) × 2", - "answer=2 × (50 + 150 + 100 + 25) ", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration( - "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", - "answer=2 * (50 + 150 + 100 + 25) ", - "input=2 × (50 + 150 + 100 + 25)" - ), - Iteration("2+5==5+2", "answer=2+5", "input=5+2"), - Iteration("5+2==5+2", "answer=5+2", "input=5+2"), - Iteration("6 + 4!=6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)"), - Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)"), - Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)"), - Iteration("− (− 4) + 6==6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)"), - Iteration("10^−5 * 3!=3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5"), - Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5"), - Iteration( - "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "200 + 30 + 4 + 0.5 + 0.06 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "0.06 + 0.5 + 4 + 30 + 200 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration("4x^2+20x==4*x^2+20x", "answer=4x^2+20x", "input=4*x^2+20x"), - Iteration("3+x-5==3+x-5", "answer=3+x-5", "input=3+x-5"), - Iteration("Z+A-Z==Z+A-Z", "answer=Z+A-Z", "input=Z+A-Z"), - Iteration("6C - 5A -1==6C - 5A -1", "answer=6C - 5A -1", "input=6C - 5A -1"), - Iteration("5Z-w==5*Z-w", "answer=5Z-w", "input=5*Z-w"), - Iteration("5*Z-w==5*Z-w", "answer=5*Z-w", "input=5*Z-w"), - Iteration("LS-3S+L==L*S-3S+L", "answer=LS-3S+L", "input=L*S-3S+L"), - Iteration("L*S-3S+L==L*S-3S+L", "answer=L*S-3S+L", "input=L*S-3S+L"), - Iteration("L*S-3*S+L==L*S-3S+L", "answer=L*S-3*S+L", "input=L*S-3S+L"), - Iteration("LS-3*S+L==L*S-3S+L", "answer=LS-3*S+L", "input=L*S-3S+L"), - Iteration("9x^2 − 6x + 1==9x^2 − 6x + 1", "answer=9x^2 − 6x + 1", "input=9x^2 − 6x + 1"), - Iteration("c*b-c==c*b-c", "answer=c*b-c", "input=c*b-c"), - Iteration("bc-c==c*b-c", "answer=bc-c", "input=c*b-c"), - Iteration("cb-c==c*b-c", "answer=cb-c", "input=c*b-c"), - Iteration("-c+bc==c*b-c", "answer=-c+bc", "input=c*b-c"), - Iteration("-c+cb==c*b-c", "answer=-c+cb", "input=c*b-c"), - Iteration("x^2+y+4x==x^2+y+4x", "answer=x^2+y+4x", "input=x^2+y+4x"), - Iteration("y+4x+x^2==x^2+y+4x", "answer=y+4x+x^2", "input=x^2+y+4x"), - Iteration("x^2+4x+y==x^2+y+4x", "answer=x^2+4x+y", "input=x^2+y+4x"), - Iteration("Y+5==Y+5", "answer=Y+5", "input=Y+5"), - Iteration("5+Y==Y+5", "answer=5+Y", "input=Y+5"), - Iteration( - "a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "2a*b + 2bc + 2a*c + a^2 + b^2 + c^2==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=2a*b + 2bc + 2a*c + a^2 + b^2 + c^2", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration("1 - 6x + 9x^2==9x^2 − 6x + 1", "answer=1 - 6x + 9x^2", "input=9x^2 − 6x + 1"), - Iteration("9x^2 + 1 - 6x==9x^2 − 6x + 1", "answer=9x^2 + 1 - 6x", "input=9x^2 − 6x + 1"), - Iteration("2+1+x==x+1+2", "answer=2+1+x", "input=x+1+2"), - Iteration("1+2+x==x+1+2", "answer=1+2+x", "input=x+1+2"), - Iteration("1+x+2==x+1+2", "answer=1+x+2", "input=x+1+2"), - Iteration("2+x+1==x+1+2", "answer=2+x+1", "input=x+1+2"), - Iteration("(x+1)+2==x+1+2", "answer=(x+1)+2", "input=x+1+2"), - Iteration("x + (1+2)==x+1+2", "answer=x + (1+2)", "input=x+1+2"), - Iteration( - "y+1+ 9x(x − 6)==9x(x − 6) + 1+ y", "answer=y+1+ 9x(x − 6)", "input=9x(x − 6) + 1+ y" - ), - Iteration("1+y+9x(x − 6)==9x(x − 6) + 1+ y", "answer=1+y+9x(x − 6)", "input=9x(x − 6) + 1+ y"), - Iteration( - "1 + 9x(x − 6) + y==9x(x − 6) + 1+ y", "answer=1 + 9x(x − 6) + y", "input=9x(x − 6) + 1+ y" - ), - Iteration( - "(y+1)+9x(x − 6)==9x(x − 6) + 1+ y", "answer=(y+1)+9x(x − 6)", "input=9x(x − 6) + 1+ y" - ), - Iteration( - "(x^2 − x)/3 − 4y==(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "-4y + (x^2 − x)/3==(x^2 − x)/3 − 4y", "answer=-4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" - ), - Iteration("(3x -1)^2==(3x-1)^2", "answer=(3x -1)^2", "input=(3x-1)^2"), - Iteration("(2+6+3+4)*2==2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)"), - Iteration("(2+6+3+4) × 2==2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)"), - Iteration( - "3 - (6 * 2) + 15==15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" - ), - Iteration( - "15 - (2 × 6) + 3==15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2* ( 25+50+100+150)==(50 + 150 + 100 + 25) × 2", - "answer=2* ( 25+50+100+150)", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration("20x+4x^2==4*x^2+20x", "answer=20x+4x^2", "input=4*x^2+20x"), - Iteration("x-5+3==3+x-5", "answer=x-5+3", "input=3+x-5"), - Iteration("-5+3+x==3+x-5", "answer=-5+3+x", "input=3+x-5"), - Iteration("-5+x+3==3+x-5", "answer=-5+x+3", "input=3+x-5"), - Iteration("3+(x-5)==3+x-5", "answer=3+(x-5)", "input=3+x-5"), - Iteration("A+Z-Z==Z+A-Z", "answer=A+Z-Z", "input=Z+A-Z"), - Iteration("Z+(A-Z)==Z+A-Z", "answer=Z+(A-Z)", "input=Z+A-Z"), - Iteration("6C - (5A+1)==6C - 5A -1", "answer=6C - (5A+1)", "input=6C - 5A -1"), - Iteration("-5A-1+6C==6C - 5A -1", "answer=-5A-1+6C", "input=6C - 5A -1"), - Iteration("-W+5Z==5*Z-W", "answer=-W+5Z", "input=5*Z-W"), - Iteration("L+LS-3S==L*S-3S+L", "answer=L+LS-3S", "input=L*S-3S+L"), - Iteration( - "- 4y + (x^2 − x)/3==(x^2 − x)/3 − 4y", "answer=- 4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ) + @Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration( + "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "2 × (50 + 150 + 100 + 25) ==(50 + 150 + 100 + 25) × 2", + "answer=2 × (50 + 150 + 100 + 25) ", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration( + "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", + "answer=2 * (50 + 150 + 100 + 25) ", + "input=2 × (50 + 150 + 100 + 25)" + ) + @Iteration("2+5==5+2", "answer=2+5", "input=5+2") + @Iteration("5+2==5+2", "answer=5+2", "input=5+2") + @Iteration("6 + 4!=6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)") + @Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)") + @Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)") + @Iteration("− (− 4) + 6==6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)") + @Iteration("10^−5 * 3!=3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5") + @Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5") + @Iteration( + "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "200 + 30 + 4 + 0.5 + 0.06 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "0.06 + 0.5 + 4 + 30 + 200 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("4x^2+20x==4*x^2+20x", "answer=4x^2+20x", "input=4*x^2+20x") + @Iteration("3+x-5==3+x-5", "answer=3+x-5", "input=3+x-5") + @Iteration("Z+A-Z==Z+A-Z", "answer=Z+A-Z", "input=Z+A-Z") + @Iteration("6C - 5A -1==6C - 5A -1", "answer=6C - 5A -1", "input=6C - 5A -1") + @Iteration("5Z-w==5*Z-w", "answer=5Z-w", "input=5*Z-w") + @Iteration("5*Z-w==5*Z-w", "answer=5*Z-w", "input=5*Z-w") + @Iteration("LS-3S+L==L*S-3S+L", "answer=LS-3S+L", "input=L*S-3S+L") + @Iteration("L*S-3S+L==L*S-3S+L", "answer=L*S-3S+L", "input=L*S-3S+L") + @Iteration("L*S-3*S+L==L*S-3S+L", "answer=L*S-3*S+L", "input=L*S-3S+L") + @Iteration("LS-3*S+L==L*S-3S+L", "answer=LS-3*S+L", "input=L*S-3S+L") + @Iteration("9x^2 − 6x + 1==9x^2 − 6x + 1", "answer=9x^2 − 6x + 1", "input=9x^2 − 6x + 1") + @Iteration("c*b-c==c*b-c", "answer=c*b-c", "input=c*b-c") + @Iteration("bc-c==c*b-c", "answer=bc-c", "input=c*b-c") + @Iteration("cb-c==c*b-c", "answer=cb-c", "input=c*b-c") + @Iteration("-c+bc==c*b-c", "answer=-c+bc", "input=c*b-c") + @Iteration("-c+cb==c*b-c", "answer=-c+cb", "input=c*b-c") + @Iteration("x^2+y+4x==x^2+y+4x", "answer=x^2+y+4x", "input=x^2+y+4x") + @Iteration("y+4x+x^2==x^2+y+4x", "answer=y+4x+x^2", "input=x^2+y+4x") + @Iteration("x^2+4x+y==x^2+y+4x", "answer=x^2+4x+y", "input=x^2+y+4x") + @Iteration("Y+5==Y+5", "answer=Y+5", "input=Y+5") + @Iteration("5+Y==Y+5", "answer=5+Y", "input=Y+5") + @Iteration( + "a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2+ 2a*b + 2a*c + 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2+ 2a*b + 2bc + 2a*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "2a*b + 2bc + 2a*c + a^2 + b^2 + c^2==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=2a*b + 2bc + 2a*c + a^2 + b^2 + c^2", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=2a*b + b^2 + c^2+ a^2 + 2bc + 2a*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration("1 - 6x + 9x^2==9x^2 − 6x + 1", "answer=1 - 6x + 9x^2", "input=9x^2 − 6x + 1") + @Iteration("9x^2 + 1 - 6x==9x^2 − 6x + 1", "answer=9x^2 + 1 - 6x", "input=9x^2 − 6x + 1") + @Iteration("2+1+x==x+1+2", "answer=2+1+x", "input=x+1+2") + @Iteration("1+2+x==x+1+2", "answer=1+2+x", "input=x+1+2") + @Iteration("1+x+2==x+1+2", "answer=1+x+2", "input=x+1+2") + @Iteration("2+x+1==x+1+2", "answer=2+x+1", "input=x+1+2") + @Iteration("(x+1)+2==x+1+2", "answer=(x+1)+2", "input=x+1+2") + @Iteration("x + (1+2)==x+1+2", "answer=x + (1+2)", "input=x+1+2") + @Iteration( + "y+1+ 9x(x − 6)==9x(x − 6) + 1+ y", "answer=y+1+ 9x(x − 6)", "input=9x(x − 6) + 1+ y" + ) + @Iteration("1+y+9x(x − 6)==9x(x − 6) + 1+ y", "answer=1+y+9x(x − 6)", "input=9x(x − 6) + 1+ y") + @Iteration( + "1 + 9x(x − 6) + y==9x(x − 6) + 1+ y", "answer=1 + 9x(x − 6) + y", "input=9x(x − 6) + 1+ y" + ) + @Iteration( + "(y+1)+9x(x − 6)==9x(x − 6) + 1+ y", "answer=(y+1)+9x(x − 6)", "input=9x(x − 6) + 1+ y" + ) + @Iteration( + "(x^2 − x)/3 − 4y==(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "-4y + (x^2 − x)/3==(x^2 − x)/3 − 4y", "answer=-4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" + ) + @Iteration("(3x -1)^2==(3x-1)^2", "answer=(3x -1)^2", "input=(3x-1)^2") + @Iteration("(2+6+3+4)*2==2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)") + @Iteration("(2+6+3+4) × 2==2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)") + @Iteration( + "3 - (6 * 2) + 15==15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "15 - (2 × 6) + 3==15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "2* ( 25+50+100+150)==(50 + 150 + 100 + 25) × 2", + "answer=2* ( 25+50+100+150)", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration("20x+4x^2==4*x^2+20x", "answer=20x+4x^2", "input=4*x^2+20x") + @Iteration("x-5+3==3+x-5", "answer=x-5+3", "input=3+x-5") + @Iteration("-5+3+x==3+x-5", "answer=-5+3+x", "input=3+x-5") + @Iteration("-5+x+3==3+x-5", "answer=-5+x+3", "input=3+x-5") + @Iteration("3+(x-5)==3+x-5", "answer=3+(x-5)", "input=3+x-5") + @Iteration("A+Z-Z==Z+A-Z", "answer=A+Z-Z", "input=Z+A-Z") + @Iteration("Z+(A-Z)==Z+A-Z", "answer=Z+(A-Z)", "input=Z+A-Z") + @Iteration("6C - (5A+1)==6C - 5A -1", "answer=6C - (5A+1)", "input=6C - 5A -1") + @Iteration("-5A-1+6C==6C - 5A -1", "answer=-5A-1+6C", "input=6C - 5A -1") + @Iteration("-W+5Z==5*Z-W", "answer=-W+5Z", "input=5*Z-W") + @Iteration("L+LS-3S==L*S-3S+L", "answer=L+LS-3S", "input=L*S-3S+L") + @Iteration( + "- 4y + (x^2 − x)/3==(x^2 − x)/3 − 4y", "answer=- 4y + (x^2 − x)/3", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2+ b^2 + c^2 + 2bc + 2a*c + 2a*b", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" ) fun testMatches_assortedExpressions_withMatchingCharacteristics_returnsTrue() { val answerExpression = createMathExpression(answer) @@ -403,191 +384,189 @@ class AlgebraicExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvi } @Test - @RunParameterized( - Iteration("10!=6 − (− 4)", "answer=10", "input=6 − (− 4)"), - Iteration("6 + 2^2!=6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)"), - Iteration("3 * 2 − (− 4)!=6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)"), - Iteration("100/10!=6 − (− 4)", "answer=100/10", "input=6 − (− 4)"), - Iteration("3/(10 * 10^4)!=3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5"), - Iteration( - "1234.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "123456/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456/100", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "61728/50!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=61728/50", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1234 + 56/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234 + 56/100", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1230 + 4.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1230 + 4.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "2 * 2 * 3 * 3 * 1!=2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" - ), - Iteration("2 * 2 * 9!=2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3"), - Iteration("4 * 3^2!=2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3"), - Iteration("8/2 * 3 * 3!=2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration("36!=2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3"), - Iteration("sqrt(4-2)!=sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)"), - Iteration( - "(a+ b)^2 + c^2 + 2bc + 2a*c!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(a+ b)^2 + c^2 + 2bc + 2a*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(a+b+c)^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", "answer=(a+b+c)^2", "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(-a -b -c)^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(-a -b -c)^2", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "x(x − 1)/3 −4y!=(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 −4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "x^2/3 − x/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x^2/3 − x/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "x^2/3 − (x/3 + 4y)!=(x^2 − x)/3 − 4y", "answer=x^2/3 − (x/3 + 4y)", "input=(x^2 − x)/3 − 4y" - ), - Iteration("√(3x −1)4!=(3x-1)^2", "answer=√(3x −1)4", "input=(3x-1)^2"), - Iteration("3x(3x - 2) + 1!=(3x-1)^2", "answer=3x(3x - 2) + 1", "input=(3x-1)^2"), - Iteration("3(3x^2) - 6x +1!=(3x-1)^2", "answer=3(3x^2) - 6x +1", "input=(3x-1)^2"), - Iteration("2x!=sqrt(4x^2)", "answer=2x", "input=sqrt(4x^2)"), - Iteration("x^2+2x+1!=(x+1)^2", "answer=x^2+2x+1", "input=(x+1)^2"), - Iteration("x^2-1!=(x+1)(x-1)", "answer=x^2-1", "input=(x+1)(x-1)"), - Iteration("x+1!=(x^2+2x+1)/(x+1)", "answer=x+1", "input=(x^2+2x+1)/(x+1)"), - Iteration("x-1!=(x^2-1)/(x+1)", "answer=x-1", "input=(x^2-1)/(x+1)"), - Iteration("x+1!=(x^2-1)/(x-1)", "answer=x+1", "input=(x^2-1)/(x-1)"), - Iteration("-3x!=(-27x^3)^(1/3)", "answer=-3x", "input=(-27x^3)^(1/3)"), - Iteration("1!=(x^2-1)/(x^2-1)", "answer=1", "input=(x^2-1)/(x^2-1)"), - Iteration("2*(6+3+4) + 4!=2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)"), - Iteration("2*(2+6+3) + 8!=2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)"), - Iteration("15 - 12 + 3!=15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3"), - Iteration( - "2 *(50 + 150) + 2*(100 + 25)!=(50 + 150 + 100 + 25) × 2", - "answer=2 *(50 + 150) + 2*(100 + 25)", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5"), - Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5"), - Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5"), - Iteration("30 * 10^−6!=3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5"), - Iteration("0.00003!=3 * 10^-5", "answer=0.00003", "input=3 * 10^-5"), - Iteration("3/10^5!=3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5"), - Iteration( - "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("3 *2 – (− 4)!=6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)"), - Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)"), - Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)"), - Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)"), - Iteration("7!=5+2", "answer=7", "input=5+2"), - Iteration("3+4!=5+2", "answer=3+4", "input=5+2"), - Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3"), - Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration("A!=Z+A-Z", "answer=A", "input=Z+A-Z"), - Iteration("L(1+S)-3S!=L*S-3S+L", "answer=L(1+S)-3S", "input=L*S-3S+L"), - Iteration("S(L-3)+L!=L*S-3S+L", "answer=S(L-3)+L", "input=L*S-3S+L"), - Iteration( - "x(x − 1)/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 − x) * 3^-1 − 4y!=(x^2 − x)/3 − 4y", - "answer=(x^2 − x) * 3^-1 − 4y", - "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "x(x^2 − x)/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 − x)/3 + 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 + 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 + x)/3 - 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 + x)/3 - 4y", "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "(x^2 − x)*0.33 - 4y!=(x^2 − x)/3 − 4y", - "answer=(x^2 − x)*0.33 - 4y", - "input=(x^2 − x)/3 − 4y" - ), - Iteration( - "a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c==a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a^2 + b^2 + c^2 + 2(a*b + a*c + bc)!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2 + 2(a*b + a*c + bc)", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(a + b)^2 + c^2 + 2a*c + 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(a + b)^2 + c^2 + 2a*c + 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "(a + b + c)^3!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=(a + b + c)^3", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a^2 + b^2 + c^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration( - "a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", - "answer=a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc", - "input=a^2+b^2+c^2+2a*b+2a*c+2bc" - ), - Iteration("(3x − 1)^2!=9x^2 − 6x + 1", "answer=(3x − 1)^2", "input=9x^2 − 6x + 1"), - Iteration("3x(3x − 2) + 1!=9x^2 − 6x + 1", "answer=3x(3x − 2) + 1", "input=9x^2 − 6x + 1"), - Iteration("3(3x^2 − 2x) + 1!=9x^2 − 6x + 1", "answer=3(3x^2 − 2x) + 1", "input=9x^2 − 6x + 1"), - Iteration("(3x)^2 − 6x + 1!=9x^2 − 6x + 1", "answer=(3x)^2 − 6x + 1", "input=9x^2 − 6x + 1"), - Iteration("c(b-1)!=c*b-c", "answer=c(b-1)", "input=c*b-c"), - Iteration("x(x+4)+y!=x^2+y+4x", "answer=x(x+4)+y", "input=x^2+y+4x"), - Iteration("Y!=Y+5", "answer=Y", "input=Y+5"), - Iteration("5!=Y+5", "answer=5", "input=Y+5"), - Iteration("x+3!=x+1+2", "answer=x+3", "input=x+1+2"), - Iteration("(1 - 3x)^2!=(3x-1)^2", "answer=(1 - 3x)^2", "input=(3x-1)^2"), - Iteration("9x^2 - 6x - 1!=(3x-1)^2", "answer=9x^2 - 6x - 1", "input=(3x-1)^2"), - Iteration("(3x −1)!=(3x-1)^2", "answer=(3x −1)", "input=(3x-1)^2"), - Iteration("2x!=sqrt(2x)^2", "answer=2x", "input=sqrt(2x)^2"), - Iteration("2x!=sqrt(-4x^2)", "answer=2x", "input=sqrt(-4x^2)"), - Iteration("x^2+2x+1!=(x+2)^2", "answer=x^2+2x+1", "input=(x+2)^2"), - Iteration("x^2-1!=(x+1)(1-x)", "answer=x^2-1", "input=(x+1)(1-x)"), - Iteration("x+1!=(x^2+2x+1)/(x-1)", "answer=x+1", "input=(x^2+2x+1)/(x-1)"), - Iteration("x-1!=(x^2-1)/x", "answer=x-1", "input=(x^2-1)/x"), - Iteration("x+1!=(x^2-1)/(x-2)", "answer=x+1", "input=(x^2-1)/(x-2)"), - Iteration("-3x!=(9x^3)^(1/3)", "answer=-3x", "input=(9x^3)^(1/3)") + @Iteration("10!=6 − (− 4)", "answer=10", "input=6 − (− 4)") + @Iteration("6 + 2^2!=6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)") + @Iteration("3 * 2 − (− 4)!=6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)") + @Iteration("100/10!=6 − (− 4)", "answer=100/10", "input=6 − (− 4)") + @Iteration("3/(10 * 10^4)!=3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5") + @Iteration( + "1234.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "123456/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456/100", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "61728/50!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=61728/50", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1234 + 56/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234 + 56/100", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1230 + 4.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1230 + 4.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "2 * 2 * 3 * 3 * 1!=2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" + ) + @Iteration("2 * 2 * 9!=2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3") + @Iteration("4 * 3^2!=2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3") + @Iteration("8/2 * 3 * 3!=2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("36!=2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3") + @Iteration("sqrt(4-2)!=sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)") + @Iteration( + "(a+ b)^2 + c^2 + 2bc + 2a*c!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(a+ b)^2 + c^2 + 2bc + 2a*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(a+b+c)^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", "answer=(a+b+c)^2", "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(-a -b -c)^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(-a -b -c)^2", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "x(x − 1)/3 −4y!=(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 −4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "x^2/3 − x/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x^2/3 − x/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "x^2/3 − (x/3 + 4y)!=(x^2 − x)/3 − 4y", "answer=x^2/3 − (x/3 + 4y)", "input=(x^2 − x)/3 − 4y" + ) + @Iteration("√(3x −1)4!=(3x-1)^2", "answer=√(3x −1)4", "input=(3x-1)^2") + @Iteration("3x(3x - 2) + 1!=(3x-1)^2", "answer=3x(3x - 2) + 1", "input=(3x-1)^2") + @Iteration("3(3x^2) - 6x +1!=(3x-1)^2", "answer=3(3x^2) - 6x +1", "input=(3x-1)^2") + @Iteration("2x!=sqrt(4x^2)", "answer=2x", "input=sqrt(4x^2)") + @Iteration("x^2+2x+1!=(x+1)^2", "answer=x^2+2x+1", "input=(x+1)^2") + @Iteration("x^2-1!=(x+1)(x-1)", "answer=x^2-1", "input=(x+1)(x-1)") + @Iteration("x+1!=(x^2+2x+1)/(x+1)", "answer=x+1", "input=(x^2+2x+1)/(x+1)") + @Iteration("x-1!=(x^2-1)/(x+1)", "answer=x-1", "input=(x^2-1)/(x+1)") + @Iteration("x+1!=(x^2-1)/(x-1)", "answer=x+1", "input=(x^2-1)/(x-1)") + @Iteration("-3x!=(-27x^3)^(1/3)", "answer=-3x", "input=(-27x^3)^(1/3)") + @Iteration("1!=(x^2-1)/(x^2-1)", "answer=1", "input=(x^2-1)/(x^2-1)") + @Iteration("2*(6+3+4) + 4!=2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)") + @Iteration("2*(2+6+3) + 8!=2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)") + @Iteration("15 - 12 + 3!=15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3") + @Iteration( + "2 *(50 + 150) + 2*(100 + 25)!=(50 + 150 + 100 + 25) × 2", + "answer=2 *(50 + 150) + 2*(100 + 25)", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5") + @Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5") + @Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5") + @Iteration("30 * 10^−6!=3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5") + @Iteration("0.00003!=3 * 10^-5", "answer=0.00003", "input=3 * 10^-5") + @Iteration("3/10^5!=3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5") + @Iteration( + "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration("3 *2 – (− 4)!=6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)") + @Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)") + @Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)") + @Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)") + @Iteration("7!=5+2", "answer=7", "input=5+2") + @Iteration("3+4!=5+2", "answer=3+4", "input=5+2") + @Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3") + @Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("A!=Z+A-Z", "answer=A", "input=Z+A-Z") + @Iteration("L(1+S)-3S!=L*S-3S+L", "answer=L(1+S)-3S", "input=L*S-3S+L") + @Iteration("S(L-3)+L!=L*S-3S+L", "answer=S(L-3)+L", "input=L*S-3S+L") + @Iteration( + "x(x − 1)/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x(x − 1)/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 − x) * 3^-1 − 4y!=(x^2 − x)/3 − 4y", + "answer=(x^2 − x) * 3^-1 − 4y", + "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "x(x^2 − x)/3 − 4y!=(x^2 − x)/3 − 4y", "answer=x(x^2 − x)/3 − 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 − x)/3 + 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 − x)/3 + 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 + x)/3 - 4y!=(x^2 − x)/3 − 4y", "answer=(x^2 + x)/3 - 4y", "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "(x^2 − x)*0.33 - 4y!=(x^2 − x)/3 − 4y", + "answer=(x^2 − x)*0.33 - 4y", + "input=(x^2 − x)/3 − 4y" + ) + @Iteration( + "a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c==a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a*a + b*b + c*c + 2*a*b + 2*a*c + 2*b*c", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a^2 + b^2 + c^2 + 2(a*b + a*c + bc)!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2 + 2(a*b + a*c + bc)", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(a + b)^2 + c^2 + 2a*c + 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(a + b)^2 + c^2 + 2a*c + 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a * a + b * b + c^3/c + 2a*b + 2a*c + 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "(a + b + c)^3!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=(a + b + c)^3", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a^2 + b^2 + c^2!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" + ) + @Iteration( + "a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc!=a^2+b^2+c^2+2a*b+2a*c+2bc", + "answer=a^2 + b^2 + c^2- 2a*b - 2a*c - 2bc", + "input=a^2+b^2+c^2+2a*b+2a*c+2bc" ) + @Iteration("(3x − 1)^2!=9x^2 − 6x + 1", "answer=(3x − 1)^2", "input=9x^2 − 6x + 1") + @Iteration("3x(3x − 2) + 1!=9x^2 − 6x + 1", "answer=3x(3x − 2) + 1", "input=9x^2 − 6x + 1") + @Iteration("3(3x^2 − 2x) + 1!=9x^2 − 6x + 1", "answer=3(3x^2 − 2x) + 1", "input=9x^2 − 6x + 1") + @Iteration("(3x)^2 − 6x + 1!=9x^2 − 6x + 1", "answer=(3x)^2 − 6x + 1", "input=9x^2 − 6x + 1") + @Iteration("c(b-1)!=c*b-c", "answer=c(b-1)", "input=c*b-c") + @Iteration("x(x+4)+y!=x^2+y+4x", "answer=x(x+4)+y", "input=x^2+y+4x") + @Iteration("Y!=Y+5", "answer=Y", "input=Y+5") + @Iteration("5!=Y+5", "answer=5", "input=Y+5") + @Iteration("x+3!=x+1+2", "answer=x+3", "input=x+1+2") + @Iteration("(1 - 3x)^2!=(3x-1)^2", "answer=(1 - 3x)^2", "input=(3x-1)^2") + @Iteration("9x^2 - 6x - 1!=(3x-1)^2", "answer=9x^2 - 6x - 1", "input=(3x-1)^2") + @Iteration("(3x −1)!=(3x-1)^2", "answer=(3x −1)", "input=(3x-1)^2") + @Iteration("2x!=sqrt(2x)^2", "answer=2x", "input=sqrt(2x)^2") + @Iteration("2x!=sqrt(-4x^2)", "answer=2x", "input=sqrt(-4x^2)") + @Iteration("x^2+2x+1!=(x+2)^2", "answer=x^2+2x+1", "input=(x+2)^2") + @Iteration("x^2-1!=(x+1)(1-x)", "answer=x^2-1", "input=(x+1)(1-x)") + @Iteration("x+1!=(x^2+2x+1)/(x-1)", "answer=x+1", "input=(x^2+2x+1)/(x-1)") + @Iteration("x-1!=(x^2-1)/x", "answer=x-1", "input=(x^2-1)/x") + @Iteration("x+1!=(x^2-1)/(x-2)", "answer=x+1", "input=(x^2-1)/(x-2)") + @Iteration("-3x!=(9x^3)^(1/3)", "answer=-3x", "input=(9x^3)^(1/3)") fun testMatches_assortedExpressions_withoutMatchingCharacteristics_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputIsEquivalentToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputIsEquivalentToRuleClassifierProviderTest.kt index 11d8bbbaac1..9435187bb25 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputIsEquivalentToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputIsEquivalentToRuleClassifierProviderTest.kt @@ -19,7 +19,6 @@ import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -62,10 +61,8 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=1!=y=1", "answer=y=1", "input=y=1"), - Iteration("1=y!=1=y", "answer=1=y", "input=1=y") - ) + @Iteration("y=1!=y=1", "answer=y=1", "input=y=1") + @Iteration("1=y!=1=y", "answer=1=y", "input=1=y") fun testMatches_answerHasDisallowedVariable_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -79,15 +76,13 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("0=1==0=1", "answer=0=1", "input=0=1"), - Iteration("y=0==y=0", "answer=y=0", "input=y=0"), - Iteration("y=1==y=1", "answer=y=1", "input=y=1"), - Iteration("0=y==0=y", "answer=0=y", "input=0=y"), - Iteration("1=y==1=y", "answer=1=y", "input=1=y"), - Iteration("y=x==y=x", "answer=y=x", "input=y=x"), - Iteration("x=y==x=y", "answer=x=y", "input=x=y") - ) + @Iteration("0=1==0=1", "answer=0=1", "input=0=1") + @Iteration("y=0==y=0", "answer=y=0", "input=y=0") + @Iteration("y=1==y=1", "answer=y=1", "input=y=1") + @Iteration("0=y==0=y", "answer=0=y", "input=0=y") + @Iteration("1=y==1=y", "answer=1=y", "input=1=y") + @Iteration("y=x==y=x", "answer=y=x", "input=y=x") + @Iteration("x=y==x=y", "answer=x=y", "input=x=y") fun testMatches_sameSingleTerms_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -99,14 +94,12 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=-x==y=-x", "answer=y=-x", "input=y=-x"), - Iteration("-y=x==-y=x", "answer=-y=x", "input=-y=x"), - Iteration("y=3.14+x==y=3.14+x", "answer=y=3.14+x", "input=y=3.14+x"), - Iteration("y=x+y+z==y=x+y+z", "answer=y=x+y+z", "input=y=x+y+z"), - Iteration("y=x/2/3==y=x/2/3", "answer=y=x/2/3", "input=y=x/2/3"), - Iteration("y=x^2==y=x^2", "answer=y=x^2", "input=y=x^2") - ) + @Iteration("y=-x==y=-x", "answer=y=-x", "input=y=-x") + @Iteration("-y=x==-y=x", "answer=-y=x", "input=-y=x") + @Iteration("y=3.14+x==y=3.14+x", "answer=y=3.14+x", "input=y=3.14+x") + @Iteration("y=x+y+z==y=x+y+z", "answer=y=x+y+z", "input=y=x+y+z") + @Iteration("y=x/2/3==y=x/2/3", "answer=y=x/2/3", "input=y=x/2/3") + @Iteration("y=x^2==y=x^2", "answer=y=x^2", "input=y=x^2") fun testMatches_sameSingleOperations_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -118,10 +111,8 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=x/y/z!=y=x/y/z", "answer=y=x/y/z", "input=y=x/y/z"), - Iteration("y=sqrt(x)!=y=sqrt(x)", "answer=y=sqrt(x)", "input=y=sqrt(x)") - ) + @Iteration("y=x/y/z!=y=x/y/z", "answer=y=x/y/z", "input=y=x/y/z") + @Iteration("y=sqrt(x)!=y=sqrt(x)", "answer=y=sqrt(x)", "input=y=sqrt(x)") fun testMatches_sameSingleOperations_thatCannotBecomePolynomials_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -134,17 +125,15 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=1!=y=0", "answer=y=1", "input=y=0"), - Iteration("y=0!=y=1", "answer=y=0", "input=y=1"), - Iteration("y=3.14!=y=1", "answer=y=3.14", "input=y=1"), - Iteration("y=1!=y=3.14", "answer=y=1", "input=y=3.14"), - Iteration("y=x!=y=3.14", "answer=y=x", "input=y=3.14"), - Iteration("y=1!=y=x", "answer=y=1", "input=y=x"), - Iteration("y=3.14!=y=x", "answer=y=3.14", "input=y=x"), - Iteration("y=z!=y=x", "answer=y=z", "input=y=x"), - Iteration("y=x!=y=z", "answer=y=x", "input=y=z") - ) + @Iteration("y=1!=y=0", "answer=y=1", "input=y=0") + @Iteration("y=0!=y=1", "answer=y=0", "input=y=1") + @Iteration("y=3.14!=y=1", "answer=y=3.14", "input=y=1") + @Iteration("y=1!=y=3.14", "answer=y=1", "input=y=3.14") + @Iteration("y=x!=y=3.14", "answer=y=x", "input=y=3.14") + @Iteration("y=1!=y=x", "answer=y=1", "input=y=x") + @Iteration("y=3.14!=y=x", "answer=y=3.14", "input=y=x") + @Iteration("y=z!=y=x", "answer=y=z", "input=y=x") + @Iteration("y=x!=y=z", "answer=y=x", "input=y=z") fun testMatches_differentSingleTerms_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -156,20 +145,18 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=1+x==y=x+1", "answer=y=1+x", "input=y=x+1"), - Iteration("y=z+x==y=x+z", "answer=y=z+x", "input=y=x+z"), - Iteration("y+1=x==1+y=x", "answer=y+1=x", "input=1+y=x"), - Iteration("y+z=x==z+y=x", "answer=y+z=x", "input=z+y=x"), - Iteration("x+y=1+z==y+x=z+1", "answer=x+y=1+z", "input=y+x=z+1"), - Iteration("y=-x+1==y=1-x", "answer=y=-x+1", "input=y=1-x"), - Iteration("-y+x=z==x-y=z", "answer=-y+x=z", "input=x-y=z"), - Iteration("y=x*2==y=2x", "answer=y=x*2", "input=y=2x"), - Iteration("y*2=z==2y=z", "answer=y*2=z", "input=2y=z"), - Iteration("y=3*2==y=2*3", "answer=y=3*2", "input=y=2*3"), - Iteration("y=zx==y=xz", "answer=y=zx", "input=y=xz"), - Iteration("yx=z==xy=z", "answer=yx=z", "input=xy=z") - ) + @Iteration("y=1+x==y=x+1", "answer=y=1+x", "input=y=x+1") + @Iteration("y=z+x==y=x+z", "answer=y=z+x", "input=y=x+z") + @Iteration("y+1=x==1+y=x", "answer=y+1=x", "input=1+y=x") + @Iteration("y+z=x==z+y=x", "answer=y+z=x", "input=z+y=x") + @Iteration("x+y=1+z==y+x=z+1", "answer=x+y=1+z", "input=y+x=z+1") + @Iteration("y=-x+1==y=1-x", "answer=y=-x+1", "input=y=1-x") + @Iteration("-y+x=z==x-y=z", "answer=-y+x=z", "input=x-y=z") + @Iteration("y=x*2==y=2x", "answer=y=x*2", "input=y=2x") + @Iteration("y*2=z==2y=z", "answer=y*2=z", "input=2y=z") + @Iteration("y=3*2==y=2*3", "answer=y=3*2", "input=y=2*3") + @Iteration("y=zx==y=xz", "answer=y=zx", "input=y=xz") + @Iteration("yx=z==xy=z", "answer=yx=z", "input=xy=z") fun testMatches_operationsDiffer_byCommutativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -181,20 +168,18 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=1+(2+3)==y=(1+2)+3", "answer=y=1+(2+3)", "input=y=(1+2)+3"), - Iteration("y=x+(y+z)==y=(x+y)+z", "answer=y=x+(y+z)", "input=y=(x+y)+z"), - Iteration("x+(y+z)=1==(x+y)+z=1", "answer=x+(y+z)=1", "input=(x+y)+z=1"), - Iteration( - "(x+y)+z=1+(2+3)==x+(y+z)=(1+2)+3", "answer=(x+y)+z=1+(2+3)", "input=x+(y+z)=(1+2)+3" - ), - Iteration("y=2*(3*4)==y=(2*3)*4", "answer=y=2*(3*4)", "input=y=(2*3)*4"), - Iteration("y=2*(3x)==y=(2x)*3", "answer=y=2*(3x)", "input=y=(2x)*3"), - Iteration("y=x(yz)==y=(xy)z", "answer=y=x(yz)", "input=y=(xy)z"), - Iteration("x(yz)=2==(xy)z=2", "answer=x(yz)=2", "input=(xy)z=2"), - Iteration("2*(3y)=4==(2y)*3=4", "answer=2*(3y)=4", "input=(2y)*3=4"), - Iteration("x(yz)=(2*3)*4==(xy)z=2*(3*4)", "answer=x(yz)=(2*3)*4", "input=(xy)z=2*(3*4)") + @Iteration("y=1+(2+3)==y=(1+2)+3", "answer=y=1+(2+3)", "input=y=(1+2)+3") + @Iteration("y=x+(y+z)==y=(x+y)+z", "answer=y=x+(y+z)", "input=y=(x+y)+z") + @Iteration("x+(y+z)=1==(x+y)+z=1", "answer=x+(y+z)=1", "input=(x+y)+z=1") + @Iteration( + "(x+y)+z=1+(2+3)==x+(y+z)=(1+2)+3", "answer=(x+y)+z=1+(2+3)", "input=x+(y+z)=(1+2)+3" ) + @Iteration("y=2*(3*4)==y=(2*3)*4", "answer=y=2*(3*4)", "input=y=(2*3)*4") + @Iteration("y=2*(3x)==y=(2x)*3", "answer=y=2*(3x)", "input=y=(2x)*3") + @Iteration("y=x(yz)==y=(xy)z", "answer=y=x(yz)", "input=y=(xy)z") + @Iteration("x(yz)=2==(xy)z=2", "answer=x(yz)=2", "input=(xy)z=2") + @Iteration("2*(3y)=4==(2y)*3=4", "answer=2*(3y)=4", "input=(2y)*3=4") + @Iteration("x(yz)=(2*3)*4==(xy)z=2*(3*4)", "answer=x(yz)=(2*3)*4", "input=(xy)z=2*(3*4)") fun testMatches_operationsDiffer_byAssociativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -206,18 +191,16 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=3.14-1!=y=1-3.14", "answer=y=3.14-1", "input=y=1-3.14"), - Iteration("y=1-(2-3)!=y=(1-2)-3", "answer=y=1-(2-3)", "input=y=(1-2)-3"), - Iteration("y-1=3!=1-y=3", "answer=y-1=3", "input=1-y=3"), - Iteration("x-(y-z)=3!=(x-y)-z=3", "answer=x-(y-z)=3", "input=(x-y)-z=3"), - Iteration("y=3.14/x!=y=x/3.14", "answer=y=3.14/x", "input=y=x/3.14"), - Iteration("y/x=2!=x/y=2", "answer=y/x=2", "input=x/y=2"), - Iteration("y=3.14^2!=y=2^3.14", "answer=y=3.14^2", "input=y=2^3.14"), - Iteration("(3.14^2)y=2!=(2^3.14)y=2", "answer=(3.14^2)y=2", "input=(2^3.14)y=2"), - Iteration("y=x/(y/z)!=y=(x/y)/z", "answer=y=x/(y/z)", "input=y=(x/y)/z"), - Iteration("x/(y/z)=2!=(x/y)/z=2", "answer=x/(y/z)=2", "input=(x/y)/z=2") - ) + @Iteration("y=3.14-1!=y=1-3.14", "answer=y=3.14-1", "input=y=1-3.14") + @Iteration("y=1-(2-3)!=y=(1-2)-3", "answer=y=1-(2-3)", "input=y=(1-2)-3") + @Iteration("y-1=3!=1-y=3", "answer=y-1=3", "input=1-y=3") + @Iteration("x-(y-z)=3!=(x-y)-z=3", "answer=x-(y-z)=3", "input=(x-y)-z=3") + @Iteration("y=3.14/x!=y=x/3.14", "answer=y=3.14/x", "input=y=x/3.14") + @Iteration("y/x=2!=x/y=2", "answer=y/x=2", "input=x/y=2") + @Iteration("y=3.14^2!=y=2^3.14", "answer=y=3.14^2", "input=y=2^3.14") + @Iteration("(3.14^2)y=2!=(2^3.14)y=2", "answer=(3.14^2)y=2", "input=(2^3.14)y=2") + @Iteration("y=x/(y/z)!=y=(x/y)/z", "answer=y=x/(y/z)", "input=y=(x/y)/z") + @Iteration("x/(y/z)=2!=(x/y)/z=2", "answer=x/(y/z)=2", "input=(x/y)/z=2") fun testMatches_operationsDiffer_byNonCommutativeOrAssociativeReordering_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -230,30 +213,28 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=1-2==y=-(2-1)", "answer=y=1-2", "input=y=-(2-1)"), - Iteration("y=1+2==y=1+1+1", "answer=y=1+2", "input=y=1+1+1"), - Iteration("y=1+2==y=1-(-2)", "answer=y=1+2", "input=y=1-(-2)"), - Iteration("y=4-6==y=1-2-1", "answer=y=4-6", "input=y=1-2-1"), - Iteration("y=2*3*2*2==y=2*3*4", "answer=y=2*3*2*2", "input=y=2*3*4"), - Iteration("y=-6-2==y=2*-(3+1)", "answer=y=-6-2", "input=y=2*-(3+1)"), - Iteration("y=2/3/2/2==y=2/3/4", "answer=y=2/3/2/2", "input=y=2/3/4"), - Iteration("y=2^(2+1)==y=2^3", "answer=y=2^(2+1)", "input=y=2^3"), - Iteration("y=2^(-1)==y=1/2", "answer=y=2^(-1)", "input=y=1/2"), - Iteration("z=x-y==z=-(y-x)", "answer=z=x-y", "input=z=-(y-x)"), - Iteration("y=2+x==y=1+x+1", "answer=y=2+x", "input=y=1+x+1"), - Iteration("y=1+x==y=1-(-x)", "answer=y=1+x", "input=y=1-(-x)"), - Iteration("y=-x==y=1-x-1", "answer=y=-x", "input=y=1-x-1"), - Iteration("y=4x==y=2*2*x", "answer=y=4x", "input=y=2*2*x"), - Iteration("y=2-6x==y=2*(-3x+1)", "answer=y=2-6x", "input=y=2*(-3x+1)"), - Iteration("y=x/4==y=x/2/2", "answer=y=x/4", "input=y=x/2/2"), - Iteration("y=x^(2+1)==y=x^3", "answer=y=x^(2+1)", "input=y=x^3"), - Iteration("y=x*(2^(-1))==y=x/2", "answer=y=x*(2^(-1))", "input=y=x/2"), - Iteration("y+2=x==1+1+y=x", "answer=y+2=x", "input=1+1+y=x"), - Iteration("(2^2)y=x+2==4y=x+2", "answer=(2^2)y=x+2", "input=4y=x+2"), - Iteration("y^(4-2)=3x==y^2=3x", "answer=y^(4-2)=3x", "input=y^2=3x"), - Iteration("y/2/2=3x==y/4=3x", "answer=y/2/2=3x", "input=y/4=3x") - ) + @Iteration("y=1-2==y=-(2-1)", "answer=y=1-2", "input=y=-(2-1)") + @Iteration("y=1+2==y=1+1+1", "answer=y=1+2", "input=y=1+1+1") + @Iteration("y=1+2==y=1-(-2)", "answer=y=1+2", "input=y=1-(-2)") + @Iteration("y=4-6==y=1-2-1", "answer=y=4-6", "input=y=1-2-1") + @Iteration("y=2*3*2*2==y=2*3*4", "answer=y=2*3*2*2", "input=y=2*3*4") + @Iteration("y=-6-2==y=2*-(3+1)", "answer=y=-6-2", "input=y=2*-(3+1)") + @Iteration("y=2/3/2/2==y=2/3/4", "answer=y=2/3/2/2", "input=y=2/3/4") + @Iteration("y=2^(2+1)==y=2^3", "answer=y=2^(2+1)", "input=y=2^3") + @Iteration("y=2^(-1)==y=1/2", "answer=y=2^(-1)", "input=y=1/2") + @Iteration("z=x-y==z=-(y-x)", "answer=z=x-y", "input=z=-(y-x)") + @Iteration("y=2+x==y=1+x+1", "answer=y=2+x", "input=y=1+x+1") + @Iteration("y=1+x==y=1-(-x)", "answer=y=1+x", "input=y=1-(-x)") + @Iteration("y=-x==y=1-x-1", "answer=y=-x", "input=y=1-x-1") + @Iteration("y=4x==y=2*2*x", "answer=y=4x", "input=y=2*2*x") + @Iteration("y=2-6x==y=2*(-3x+1)", "answer=y=2-6x", "input=y=2*(-3x+1)") + @Iteration("y=x/4==y=x/2/2", "answer=y=x/4", "input=y=x/2/2") + @Iteration("y=x^(2+1)==y=x^3", "answer=y=x^(2+1)", "input=y=x^3") + @Iteration("y=x*(2^(-1))==y=x/2", "answer=y=x*(2^(-1))", "input=y=x/2") + @Iteration("y+2=x==1+1+y=x", "answer=y+2=x", "input=1+1+y=x") + @Iteration("(2^2)y=x+2==4y=x+2", "answer=(2^2)y=x+2", "input=4y=x+2") + @Iteration("y^(4-2)=3x==y^2=3x", "answer=y^(4-2)=3x", "input=y^2=3x") + @Iteration("y/2/2=3x==y/4=3x", "answer=y/2/2=3x", "input=y/4=3x") fun testMatches_operationsDiffer_byDistributionAndCombining_returnTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -265,13 +246,11 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("2+x=y==y=2+x", "answer=2+x=y", "input=y=2+x"), - Iteration("-3x^3=2y^2==2y^2=-3x^3", "answer=-3x^3=2y^2", "input=2y^2=-3x^3"), - Iteration("-4+x=2+y+1-1==2+y=x-4", "answer=-4+x=2+y+1-1", "input=2+y=x-4"), - Iteration("y=x-6==2+y=x-4", "answer=y=x-6", "input=2+y=x-4"), - Iteration("(1+1+1)*x=2*y/4==y/2=3x", "answer=(1+1+1)*x=2*y/4", "input=y/2=3x") - ) + @Iteration("2+x=y==y=2+x", "answer=2+x=y", "input=y=2+x") + @Iteration("-3x^3=2y^2==2y^2=-3x^3", "answer=-3x^3=2y^2", "input=2y^2=-3x^3") + @Iteration("-4+x=2+y+1-1==2+y=x-4", "answer=-4+x=2+y+1-1", "input=2+y=x-4") + @Iteration("y=x-6==2+y=x-4", "answer=y=x-6", "input=2+y=x-4") + @Iteration("(1+1+1)*x=2*y/4==y/2=3x", "answer=(1+1+1)*x=2*y/4", "input=y/2=3x") fun testMatches_sidesRearrangedAroundEqualsSign_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -284,23 +263,21 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y = 3x^2 - 4==y = 3x^2 - 4", "answer=y = 3x^2 - 4", "input=y = 3x^2 - 4"), - Iteration("y = -4 + 3x^2==y = 3x^2 - 4", "answer=y = -4 + 3x^2", "input=y = 3x^2 - 4"), - Iteration("y = x^2*3 - 4==y = 3x^2 - 4", "answer=y = x^2*3 - 4", "input=y = 3x^2 - 4"), - Iteration("y+4=3x^2==y = 3x^2 - 4", "answer=y+4=3x^2", "input=y = 3x^2 - 4"), - Iteration("y-3x^2=-4==y = 3x^2 - 4", "answer=y-3x^2=-4", "input=y = 3x^2 - 4"), - Iteration("-4=y-3x^2==y = 3x^2 - 4", "answer=-4=y-3x^2", "input=y = 3x^2 - 4"), - Iteration("3x^2-y=4==y = 3x^2 - 4", "answer=3x^2-y=4", "input=y = 3x^2 - 4"), - Iteration("3x^2=4+y==y = 3x^2 - 4", "answer=3x^2=4+y", "input=y = 3x^2 - 4"), - Iteration("y-x^2=2x^2-4==y = 3x^2 - 4", "answer=y-x^2=2x^2-4", "input=y = 3x^2 - 4"), - Iteration("y=x*(2^(1/2))==y=sqrt(2)x", "answer=y=x*(2^(1/2))", "input=y=sqrt(2)x"), - Iteration("y − 3x^2 = -4==y = 3x^2 - 4", "answer=y − 3x^2 = -4", "input=y = 3x^2 - 4"), - Iteration("3x^2 - 4 = y==y = 3x^2 - 4", "answer=3x^2 - 4 = y", "input=y = 3x^2 - 4"), - Iteration("y − 3x^2 + 4 = 0==y = 3x^2 - 4", "answer=y − 3x^2 + 4 = 0", "input=y = 3x^2 - 4"), - Iteration("y = (3x^3 - 4x)/x==y = 3x^2 - 4", "answer=y = (3x^3 - 4x)/x", "input=y = 3x^2 - 4"), - Iteration("y^2/y = 3x^2 - 4==y = 3x^2 - 4", "answer=y^2/y = 3x^2 - 4", "input=y = 3x^2 - 4") - ) + @Iteration("y = 3x^2 - 4==y = 3x^2 - 4", "answer=y = 3x^2 - 4", "input=y = 3x^2 - 4") + @Iteration("y = -4 + 3x^2==y = 3x^2 - 4", "answer=y = -4 + 3x^2", "input=y = 3x^2 - 4") + @Iteration("y = x^2*3 - 4==y = 3x^2 - 4", "answer=y = x^2*3 - 4", "input=y = 3x^2 - 4") + @Iteration("y+4=3x^2==y = 3x^2 - 4", "answer=y+4=3x^2", "input=y = 3x^2 - 4") + @Iteration("y-3x^2=-4==y = 3x^2 - 4", "answer=y-3x^2=-4", "input=y = 3x^2 - 4") + @Iteration("-4=y-3x^2==y = 3x^2 - 4", "answer=-4=y-3x^2", "input=y = 3x^2 - 4") + @Iteration("3x^2-y=4==y = 3x^2 - 4", "answer=3x^2-y=4", "input=y = 3x^2 - 4") + @Iteration("3x^2=4+y==y = 3x^2 - 4", "answer=3x^2=4+y", "input=y = 3x^2 - 4") + @Iteration("y-x^2=2x^2-4==y = 3x^2 - 4", "answer=y-x^2=2x^2-4", "input=y = 3x^2 - 4") + @Iteration("y=x*(2^(1/2))==y=sqrt(2)x", "answer=y=x*(2^(1/2))", "input=y=sqrt(2)x") + @Iteration("y − 3x^2 = -4==y = 3x^2 - 4", "answer=y − 3x^2 = -4", "input=y = 3x^2 - 4") + @Iteration("3x^2 - 4 = y==y = 3x^2 - 4", "answer=3x^2 - 4 = y", "input=y = 3x^2 - 4") + @Iteration("y − 3x^2 + 4 = 0==y = 3x^2 - 4", "answer=y − 3x^2 + 4 = 0", "input=y = 3x^2 - 4") + @Iteration("y = (3x^3 - 4x)/x==y = 3x^2 - 4", "answer=y = (3x^3 - 4x)/x", "input=y = 3x^2 - 4") + @Iteration("y^2/y = 3x^2 - 4==y = 3x^2 - 4", "answer=y^2/y = 3x^2 - 4", "input=y = 3x^2 - 4") fun testMatches_assortedExpressions_withMatchingCharacteristics_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -313,28 +290,26 @@ class MathEquationInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y = 3x^2 - 7!=y = 3x^2 - 4", "answer=y = 3x^2 - 7", "input=y = 3x^2 - 4"), - Iteration("x^2 = 3y - 4!=y = 3x^2 - 4", "answer=x^2 = 3y - 4", "input=y = 3x^2 - 4"), - Iteration("y/(3x^2 - 4) = 1!=y = 3x^2 - 4", "answer=y/(3x^2 - 4) = 1", "input=y = 3x^2 - 4"), - Iteration("y + 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y + 3x^2 - 4 = 0", "input=y = 3x^2 - 4"), - Iteration("y^2 = 3x^2y - 4y!=y = 3x^2 - 4", "answer=y^2 = 3x^2y - 4y", "input=y = 3x^2 - 4"), - Iteration( - "y^2 * y^−1 = -12x^2!=y = 3x^2 - 4", "answer=y^2 * y^−1 = -12x^2", "input=y = 3x^2 - 4" - ), - Iteration("2 − 3 = -4!=y = 3x^2 - 4", "answer=2 − 3 = -4", "input=y = 3x^2 - 4"), - Iteration("y = 3x^2 + 4!=y = 3x^2 - 4", "answer=y = 3x^2 + 4", "input=y = 3x^2 - 4"), - Iteration("y - 4 = 3x^2!=y = 3x^2 - 4", "answer=y - 4 = 3x^2", "input=y = 3x^2 - 4"), - Iteration("y − 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y − 3x^2 - 4 = 0", "input=y = 3x^2 - 4"), - Iteration("0 = y + 3x^2 - 4!=y = 3x^2 - 4", "answer=0 = y + 3x^2 - 4", "input=y = 3x^2 - 4"), - Iteration("2 = 0!=y = 3x^2 - 4", "answer=2 = 0", "input=y = 3x^2 - 4"), - Iteration("y=3x-4!=y = 3x^2 - 4", "answer=y=3x-4", "input=y = 3x^2 - 4"), - Iteration("y - x^2 = -4!=y = 3x^2 - 4", "answer=y - x^2 = -4", "input=y = 3x^2 - 4"), - Iteration("y/sqrt(2)=x!=y=sqrt(2)x", "answer=y/sqrt(2)=x", "input=y=sqrt(2)x"), - Iteration("y/4=x!=y=4x", "answer=y/4=x", "input=y=4x"), - Iteration("y/4=16x!=y=4x", "answer=y/4=16x", "input=y=4x"), - Iteration("xy=x^2!=y=x", "answer=xy=x^2", "input=y=x") + @Iteration("y = 3x^2 - 7!=y = 3x^2 - 4", "answer=y = 3x^2 - 7", "input=y = 3x^2 - 4") + @Iteration("x^2 = 3y - 4!=y = 3x^2 - 4", "answer=x^2 = 3y - 4", "input=y = 3x^2 - 4") + @Iteration("y/(3x^2 - 4) = 1!=y = 3x^2 - 4", "answer=y/(3x^2 - 4) = 1", "input=y = 3x^2 - 4") + @Iteration("y + 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y + 3x^2 - 4 = 0", "input=y = 3x^2 - 4") + @Iteration("y^2 = 3x^2y - 4y!=y = 3x^2 - 4", "answer=y^2 = 3x^2y - 4y", "input=y = 3x^2 - 4") + @Iteration( + "y^2 * y^−1 = -12x^2!=y = 3x^2 - 4", "answer=y^2 * y^−1 = -12x^2", "input=y = 3x^2 - 4" ) + @Iteration("2 − 3 = -4!=y = 3x^2 - 4", "answer=2 − 3 = -4", "input=y = 3x^2 - 4") + @Iteration("y = 3x^2 + 4!=y = 3x^2 - 4", "answer=y = 3x^2 + 4", "input=y = 3x^2 - 4") + @Iteration("y - 4 = 3x^2!=y = 3x^2 - 4", "answer=y - 4 = 3x^2", "input=y = 3x^2 - 4") + @Iteration("y − 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y − 3x^2 - 4 = 0", "input=y = 3x^2 - 4") + @Iteration("0 = y + 3x^2 - 4!=y = 3x^2 - 4", "answer=0 = y + 3x^2 - 4", "input=y = 3x^2 - 4") + @Iteration("2 = 0!=y = 3x^2 - 4", "answer=2 = 0", "input=y = 3x^2 - 4") + @Iteration("y=3x-4!=y = 3x^2 - 4", "answer=y=3x-4", "input=y = 3x^2 - 4") + @Iteration("y - x^2 = -4!=y = 3x^2 - 4", "answer=y - x^2 = -4", "input=y = 3x^2 - 4") + @Iteration("y/sqrt(2)=x!=y=sqrt(2)x", "answer=y/sqrt(2)=x", "input=y=sqrt(2)x") + @Iteration("y/4=x!=y=4x", "answer=y/4=x", "input=y=4x") + @Iteration("y/4=16x!=y=4x", "answer=y/4=16x", "input=y=4x") + @Iteration("xy=x^2!=y=x", "answer=xy=x^2", "input=y=x") fun testMatches_assortedExpressions_withoutMatchingCharacteristics_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesExactlyWithRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesExactlyWithRuleClassifierProviderTest.kt index 7c8a7d596d1..22a7444050a 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesExactlyWithRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesExactlyWithRuleClassifierProviderTest.kt @@ -19,7 +19,6 @@ import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -62,10 +61,8 @@ class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=1!=y=1", "answer=y=1", "input=y=1"), - Iteration("1=y!=1=y", "answer=1=y", "input=1=y") - ) + @Iteration("y=1!=y=1", "answer=y=1", "input=y=1") + @Iteration("1=y!=1=y", "answer=1=y", "input=1=y") fun testMatches_answerHasDisallowedVariable_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -79,15 +76,13 @@ class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("0=1==0=1", "answer=0=1", "input=0=1"), - Iteration("y=0==y=0", "answer=y=0", "input=y=0"), - Iteration("y=1==y=1", "answer=y=1", "input=y=1"), - Iteration("0=y==0=y", "answer=0=y", "input=0=y"), - Iteration("1=y==1=y", "answer=1=y", "input=1=y"), - Iteration("y=x==y=x", "answer=y=x", "input=y=x"), - Iteration("x=y==x=y", "answer=x=y", "input=x=y") - ) + @Iteration("0=1==0=1", "answer=0=1", "input=0=1") + @Iteration("y=0==y=0", "answer=y=0", "input=y=0") + @Iteration("y=1==y=1", "answer=y=1", "input=y=1") + @Iteration("0=y==0=y", "answer=0=y", "input=0=y") + @Iteration("1=y==1=y", "answer=1=y", "input=1=y") + @Iteration("y=x==y=x", "answer=y=x", "input=y=x") + @Iteration("x=y==x=y", "answer=x=y", "input=x=y") fun testMatches_sameSingleTerms_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -99,16 +94,14 @@ class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=-x==y=-x", "answer=y=-x", "input=y=-x"), - Iteration("-y=x==-y=x", "answer=-y=x", "input=-y=x"), - Iteration("y=3.14+x==y=3.14+x", "answer=y=3.14+x", "input=y=3.14+x"), - Iteration("y=x+y+z==y=x+y+z", "answer=y=x+y+z", "input=y=x+y+z"), - Iteration("y=x/y/z==y=x/y/z", "answer=y=x/y/z", "input=y=x/y/z"), - Iteration("y=x/2/3==y=x/2/3", "answer=y=x/2/3", "input=y=x/2/3"), - Iteration("y=x^2==y=x^2", "answer=y=x^2", "input=y=x^2"), - Iteration("y=sqrt(x)==y=sqrt(x)", "answer=y=sqrt(x)", "input=y=sqrt(x)") - ) + @Iteration("y=-x==y=-x", "answer=y=-x", "input=y=-x") + @Iteration("-y=x==-y=x", "answer=-y=x", "input=-y=x") + @Iteration("y=3.14+x==y=3.14+x", "answer=y=3.14+x", "input=y=3.14+x") + @Iteration("y=x+y+z==y=x+y+z", "answer=y=x+y+z", "input=y=x+y+z") + @Iteration("y=x/y/z==y=x/y/z", "answer=y=x/y/z", "input=y=x/y/z") + @Iteration("y=x/2/3==y=x/2/3", "answer=y=x/2/3", "input=y=x/2/3") + @Iteration("y=x^2==y=x^2", "answer=y=x^2", "input=y=x^2") + @Iteration("y=sqrt(x)==y=sqrt(x)", "answer=y=sqrt(x)", "input=y=sqrt(x)") fun testMatches_sameSingleOperations_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -120,17 +113,15 @@ class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=1!=y=0", "answer=y=1", "input=y=0"), - Iteration("y=0!=y=1", "answer=y=0", "input=y=1"), - Iteration("y=3.14!=y=1", "answer=y=3.14", "input=y=1"), - Iteration("y=1!=y=3.14", "answer=y=1", "input=y=3.14"), - Iteration("y=x!=y=3.14", "answer=y=x", "input=y=3.14"), - Iteration("y=1!=y=x", "answer=y=1", "input=y=x"), - Iteration("y=3.14!=y=x", "answer=y=3.14", "input=y=x"), - Iteration("y=z!=y=x", "answer=y=z", "input=y=x"), - Iteration("y=x!=y=z", "answer=y=x", "input=y=z") - ) + @Iteration("y=1!=y=0", "answer=y=1", "input=y=0") + @Iteration("y=0!=y=1", "answer=y=0", "input=y=1") + @Iteration("y=3.14!=y=1", "answer=y=3.14", "input=y=1") + @Iteration("y=1!=y=3.14", "answer=y=1", "input=y=3.14") + @Iteration("y=x!=y=3.14", "answer=y=x", "input=y=3.14") + @Iteration("y=1!=y=x", "answer=y=1", "input=y=x") + @Iteration("y=3.14!=y=x", "answer=y=3.14", "input=y=x") + @Iteration("y=z!=y=x", "answer=y=z", "input=y=x") + @Iteration("y=x!=y=z", "answer=y=x", "input=y=z") fun testMatches_differentSingleTerms_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -142,20 +133,18 @@ class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=1+x!=y=x+1", "answer=y=1+x", "input=y=x+1"), - Iteration("y=z+x!=y=x+z", "answer=y=z+x", "input=y=x+z"), - Iteration("y+1=x!=1+y=x", "answer=y+1=x", "input=1+y=x"), - Iteration("y+z=x!=z+y=x", "answer=y+z=x", "input=z+y=x"), - Iteration("x+y=1+z!=y+x=z+1", "answer=x+y=1+z", "input=y+x=z+1"), - Iteration("y=-x+1!=y=1-x", "answer=y=-x+1", "input=y=1-x"), - Iteration("-y+x=z!=x-y=z", "answer=-y+x=z", "input=x-y=z"), - Iteration("y=x*2!=y=2x", "answer=y=x*2", "input=y=2x"), - Iteration("y*2=z!=2y=z", "answer=y*2=z", "input=2y=z"), - Iteration("y=3*2!=y=2*3", "answer=y=3*2", "input=y=2*3"), - Iteration("y=zx!=y=xz", "answer=y=zx", "input=y=xz"), - Iteration("yx=z!=xy=z", "answer=yx=z", "input=xy=z") - ) + @Iteration("y=1+x!=y=x+1", "answer=y=1+x", "input=y=x+1") + @Iteration("y=z+x!=y=x+z", "answer=y=z+x", "input=y=x+z") + @Iteration("y+1=x!=1+y=x", "answer=y+1=x", "input=1+y=x") + @Iteration("y+z=x!=z+y=x", "answer=y+z=x", "input=z+y=x") + @Iteration("x+y=1+z!=y+x=z+1", "answer=x+y=1+z", "input=y+x=z+1") + @Iteration("y=-x+1!=y=1-x", "answer=y=-x+1", "input=y=1-x") + @Iteration("-y+x=z!=x-y=z", "answer=-y+x=z", "input=x-y=z") + @Iteration("y=x*2!=y=2x", "answer=y=x*2", "input=y=2x") + @Iteration("y*2=z!=2y=z", "answer=y*2=z", "input=2y=z") + @Iteration("y=3*2!=y=2*3", "answer=y=3*2", "input=y=2*3") + @Iteration("y=zx!=y=xz", "answer=y=zx", "input=y=xz") + @Iteration("yx=z!=xy=z", "answer=yx=z", "input=xy=z") fun testMatches_operationsDiffer_byCommutativity_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -167,20 +156,18 @@ class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=1+(2+3)!=y=(1+2)+3", "answer=y=1+(2+3)", "input=y=(1+2)+3"), - Iteration("y=x+(y+z)!=y=(x+y)+z", "answer=y=x+(y+z)", "input=y=(x+y)+z"), - Iteration("x+(y+z)=1!=(x+y)+z=1", "answer=x+(y+z)=1", "input=(x+y)+z=1"), - Iteration( - "(x+y)+z=1+(2+3)!=x+(y+z)=(1+2)+3", "answer=(x+y)+z=1+(2+3)", "input=x+(y+z)=(1+2)+3" - ), - Iteration("y=2*(3*4)!=y=(2*3)*4", "answer=y=2*(3*4)", "input=y=(2*3)*4"), - Iteration("y=2*(3x)!=y=(2x)*3", "answer=y=2*(3x)", "input=y=(2x)*3"), - Iteration("y=x(yz)!=y=(xy)z", "answer=y=x(yz)", "input=y=(xy)z"), - Iteration("x(yz)=2!=(xy)z=2", "answer=x(yz)=2", "input=(xy)z=2"), - Iteration("2*(3y)=4!=(2y)*3=4", "answer=2*(3y)=4", "input=(2y)*3=4"), - Iteration("x(yz)=(2*3)*4!=(xy)z=2*(3*4)", "answer=x(yz)=(2*3)*4", "input=(xy)z=2*(3*4)") + @Iteration("y=1+(2+3)!=y=(1+2)+3", "answer=y=1+(2+3)", "input=y=(1+2)+3") + @Iteration("y=x+(y+z)!=y=(x+y)+z", "answer=y=x+(y+z)", "input=y=(x+y)+z") + @Iteration("x+(y+z)=1!=(x+y)+z=1", "answer=x+(y+z)=1", "input=(x+y)+z=1") + @Iteration( + "(x+y)+z=1+(2+3)!=x+(y+z)=(1+2)+3", "answer=(x+y)+z=1+(2+3)", "input=x+(y+z)=(1+2)+3" ) + @Iteration("y=2*(3*4)!=y=(2*3)*4", "answer=y=2*(3*4)", "input=y=(2*3)*4") + @Iteration("y=2*(3x)!=y=(2x)*3", "answer=y=2*(3x)", "input=y=(2x)*3") + @Iteration("y=x(yz)!=y=(xy)z", "answer=y=x(yz)", "input=y=(xy)z") + @Iteration("x(yz)=2!=(xy)z=2", "answer=x(yz)=2", "input=(xy)z=2") + @Iteration("2*(3y)=4!=(2y)*3=4", "answer=2*(3y)=4", "input=(2y)*3=4") + @Iteration("x(yz)=(2*3)*4!=(xy)z=2*(3*4)", "answer=x(yz)=(2*3)*4", "input=(xy)z=2*(3*4)") fun testMatches_operationsDiffer_byAssociativity_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -192,18 +179,16 @@ class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=3.14-1!=y=1-3.14", "answer=y=3.14-1", "input=y=1-3.14"), - Iteration("y=1-(2-3)!=y=(1-2)-3", "answer=y=1-(2-3)", "input=y=(1-2)-3"), - Iteration("y-1=3!=1-y=3", "answer=y-1=3", "input=1-y=3"), - Iteration("x-(y-z)=3!=(x-y)-z=3", "answer=x-(y-z)=3", "input=(x-y)-z=3"), - Iteration("y=3.14/x!=y=x/3.14", "answer=y=3.14/x", "input=y=x/3.14"), - Iteration("y/x=2!=x/y=2", "answer=y/x=2", "input=x/y=2"), - Iteration("y=3.14^2!=y=2^3.14", "answer=y=3.14^2", "input=y=2^3.14"), - Iteration("(3.14^2)y=2!=(2^3.14)y=2", "answer=(3.14^2)y=2", "input=(2^3.14)y=2"), - Iteration("y=x/(y/z)!=y=(x/y)/z", "answer=y=x/(y/z)", "input=y=(x/y)/z"), - Iteration("x/(y/z)=2!=(x/y)/z=2", "answer=x/(y/z)=2", "input=(x/y)/z=2") - ) + @Iteration("y=3.14-1!=y=1-3.14", "answer=y=3.14-1", "input=y=1-3.14") + @Iteration("y=1-(2-3)!=y=(1-2)-3", "answer=y=1-(2-3)", "input=y=(1-2)-3") + @Iteration("y-1=3!=1-y=3", "answer=y-1=3", "input=1-y=3") + @Iteration("x-(y-z)=3!=(x-y)-z=3", "answer=x-(y-z)=3", "input=(x-y)-z=3") + @Iteration("y=3.14/x!=y=x/3.14", "answer=y=3.14/x", "input=y=x/3.14") + @Iteration("y/x=2!=x/y=2", "answer=y/x=2", "input=x/y=2") + @Iteration("y=3.14^2!=y=2^3.14", "answer=y=3.14^2", "input=y=2^3.14") + @Iteration("(3.14^2)y=2!=(2^3.14)y=2", "answer=(3.14^2)y=2", "input=(2^3.14)y=2") + @Iteration("y=x/(y/z)!=y=(x/y)/z", "answer=y=x/(y/z)", "input=y=(x/y)/z") + @Iteration("x/(y/z)=2!=(x/y)/z=2", "answer=x/(y/z)=2", "input=(x/y)/z=2") fun testMatches_operationsDiffer_byNonCommutativeOrAssociativeReordering_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -216,30 +201,28 @@ class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y=1-2!=y=-(2-1)", "answer=y=1-2", "input=y=-(2-1)"), - Iteration("y=1+2!=y=1+1+1", "answer=y=1+2", "input=y=1+1+1"), - Iteration("y=1+2!=y=1-(-2)", "answer=y=1+2", "input=y=1-(-2)"), - Iteration("y=4-6!=y=1-2-1", "answer=y=4-6", "input=y=1-2-1"), - Iteration("y=2*3*2*2!=y=2*3*4", "answer=y=2*3*2*2", "input=y=2*3*4"), - Iteration("y=-6-2!=y=2*-(3+1)", "answer=y=-6-2", "input=y=2*-(3+1)"), - Iteration("y=2/3/2/2!=y=2/3/4", "answer=y=2/3/2/2", "input=y=2/3/4"), - Iteration("y=2^(2+1)!=y=2^3", "answer=y=2^(2+1)", "input=y=2^3"), - Iteration("y=2^(-1)!=y=1/2", "answer=y=2^(-1)", "input=y=1/2"), - Iteration("z=x-y!=z=-(y-x)", "answer=z=x-y", "input=z=-(y-x)"), - Iteration("y=2+x!=y=1+x+1", "answer=y=2+x", "input=y=1+x+1"), - Iteration("y=1+x!=y=1-(-x)", "answer=y=1+x", "input=y=1-(-x)"), - Iteration("y=-x!=y=1-x-1", "answer=y=-x", "input=y=1-x-1"), - Iteration("y=4x!=y=2*2*x", "answer=y=4x", "input=y=2*2*x"), - Iteration("y=2-6x!=y=2*(-3x+1)", "answer=y=2-6x", "input=y=2*(-3x+1)"), - Iteration("y=x/4!=y=x/2/2", "answer=y=x/4", "input=y=x/2/2"), - Iteration("y=x^(2+1)!=y=x^3", "answer=y=x^(2+1)", "input=y=x^3"), - Iteration("y=x*(2^(-1))!=y=x/2", "answer=y=x*(2^(-1))", "input=y=x/2"), - Iteration("y+2=x!=1+1+y=x", "answer=y+2=x", "input=1+1+y=x"), - Iteration("(2^2)y=x+2!=4y=x+2", "answer=(2^2)y=x+2", "input=4y=x+2"), - Iteration("y^(4-2)=3x!=y^2=3x", "answer=y^(4-2)=3x", "input=y^2=3x"), - Iteration("y/2/2=3x!=y/4=3x", "answer=y/2/2=3x", "input=y/4=3x") - ) + @Iteration("y=1-2!=y=-(2-1)", "answer=y=1-2", "input=y=-(2-1)") + @Iteration("y=1+2!=y=1+1+1", "answer=y=1+2", "input=y=1+1+1") + @Iteration("y=1+2!=y=1-(-2)", "answer=y=1+2", "input=y=1-(-2)") + @Iteration("y=4-6!=y=1-2-1", "answer=y=4-6", "input=y=1-2-1") + @Iteration("y=2*3*2*2!=y=2*3*4", "answer=y=2*3*2*2", "input=y=2*3*4") + @Iteration("y=-6-2!=y=2*-(3+1)", "answer=y=-6-2", "input=y=2*-(3+1)") + @Iteration("y=2/3/2/2!=y=2/3/4", "answer=y=2/3/2/2", "input=y=2/3/4") + @Iteration("y=2^(2+1)!=y=2^3", "answer=y=2^(2+1)", "input=y=2^3") + @Iteration("y=2^(-1)!=y=1/2", "answer=y=2^(-1)", "input=y=1/2") + @Iteration("z=x-y!=z=-(y-x)", "answer=z=x-y", "input=z=-(y-x)") + @Iteration("y=2+x!=y=1+x+1", "answer=y=2+x", "input=y=1+x+1") + @Iteration("y=1+x!=y=1-(-x)", "answer=y=1+x", "input=y=1-(-x)") + @Iteration("y=-x!=y=1-x-1", "answer=y=-x", "input=y=1-x-1") + @Iteration("y=4x!=y=2*2*x", "answer=y=4x", "input=y=2*2*x") + @Iteration("y=2-6x!=y=2*(-3x+1)", "answer=y=2-6x", "input=y=2*(-3x+1)") + @Iteration("y=x/4!=y=x/2/2", "answer=y=x/4", "input=y=x/2/2") + @Iteration("y=x^(2+1)!=y=x^3", "answer=y=x^(2+1)", "input=y=x^3") + @Iteration("y=x*(2^(-1))!=y=x/2", "answer=y=x*(2^(-1))", "input=y=x/2") + @Iteration("y+2=x!=1+1+y=x", "answer=y+2=x", "input=1+1+y=x") + @Iteration("(2^2)y=x+2!=4y=x+2", "answer=(2^2)y=x+2", "input=4y=x+2") + @Iteration("y^(4-2)=3x!=y^2=3x", "answer=y^(4-2)=3x", "input=y^2=3x") + @Iteration("y/2/2=3x!=y/4=3x", "answer=y/2/2=3x", "input=y/4=3x") fun testMatches_operationsDiffer_byDistributionAndCombining_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -251,13 +234,11 @@ class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("2+x=y!=y=2+x", "answer=2+x=y", "input=y=2+x"), - Iteration("-3x^3=2y^2!=2y^2=-3x^3", "answer=-3x^3=2y^2", "input=2y^2=-3x^3"), - Iteration("-4+x=2+y+1-1!=2+y=x-4", "answer=-4+x=2+y+1-1", "input=2+y=x-4"), - Iteration("y=x-6!=2+y=x-4", "answer=y=x-6", "input=2+y=x-4"), - Iteration("(1+1+1)*x=2*y/4!=y/2=3x", "answer=(1+1+1)*x=2*y/4", "input=y/2=3x") - ) + @Iteration("2+x=y!=y=2+x", "answer=2+x=y", "input=y=2+x") + @Iteration("-3x^3=2y^2!=2y^2=-3x^3", "answer=-3x^3=2y^2", "input=2y^2=-3x^3") + @Iteration("-4+x=2+y+1-1!=2+y=x-4", "answer=-4+x=2+y+1-1", "input=2+y=x-4") + @Iteration("y=x-6!=2+y=x-4", "answer=y=x-6", "input=2+y=x-4") + @Iteration("(1+1+1)*x=2*y/4!=y/2=3x", "answer=(1+1+1)*x=2*y/4", "input=y/2=3x") fun testMatches_sidesRearrangedAroundEqualsSign_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -269,9 +250,7 @@ class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y = 3x^2 - 4==y = 3x^2 - 4", "answer=y = 3x^2 - 4", "input=y = 3x^2 - 4") - ) + @Iteration("y = 3x^2 - 4==y = 3x^2 - 4", "answer=y = 3x^2 - 4", "input=y = 3x^2 - 4") fun testMatches_assortedExpressions_withMatchingCharacteristics_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -284,42 +263,40 @@ class MathEquationInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("y = -4 + 3x^2!=y = 3x^2 - 4", "answer=y = -4 + 3x^2", "input=y = 3x^2 - 4"), - Iteration("y = x^2*3 - 4!=y = 3x^2 - 4", "answer=y = x^2*3 - 4", "input=y = 3x^2 - 4"), - Iteration("y+4=3x^2!=y = 3x^2 - 4", "answer=y+4=3x^2", "input=y = 3x^2 - 4"), - Iteration("y-3x^2=-4!=y = 3x^2 - 4", "answer=y-3x^2=-4", "input=y = 3x^2 - 4"), - Iteration("-4=y-3x^2!=y = 3x^2 - 4", "answer=-4=y-3x^2", "input=y = 3x^2 - 4"), - Iteration("3x^2-y=4!=y = 3x^2 - 4", "answer=3x^2-y=4", "input=y = 3x^2 - 4"), - Iteration("3x^2=4+y!=y = 3x^2 - 4", "answer=3x^2=4+y", "input=y = 3x^2 - 4"), - Iteration("y-x^2=2x^2-4!=y = 3x^2 - 4", "answer=y-x^2=2x^2-4", "input=y = 3x^2 - 4"), - Iteration("y=x*(2^(1/2))!=y=sqrt(2)x", "answer=y=x*(2^(1/2))", "input=y=sqrt(2)x"), - Iteration("y − 3x^2 = -4!=y = 3x^2 - 4", "answer=y − 3x^2 = -4", "input=y = 3x^2 - 4"), - Iteration("3x^2 - 4 = y!=y = 3x^2 - 4", "answer=3x^2 - 4 = y", "input=y = 3x^2 - 4"), - Iteration("y = 3x^2 - 7!=y = 3x^2 - 4", "answer=y = 3x^2 - 7", "input=y = 3x^2 - 4"), - Iteration("x^2 = 3y - 4!=y = 3x^2 - 4", "answer=x^2 = 3y - 4", "input=y = 3x^2 - 4"), - Iteration("y/(3x^2 - 4) = 1!=y = 3x^2 - 4", "answer=y/(3x^2 - 4) = 1", "input=y = 3x^2 - 4"), - Iteration("y + 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y + 3x^2 - 4 = 0", "input=y = 3x^2 - 4"), - Iteration("y − 3x^2 + 4 = 0!=y = 3x^2 - 4", "answer=y − 3x^2 + 4 = 0", "input=y = 3x^2 - 4"), - Iteration("y^2 = 3x^2y - 4y!=y = 3x^2 - 4", "answer=y^2 = 3x^2y - 4y", "input=y = 3x^2 - 4"), - Iteration("y = (3x^3 - 4x)/x!=y = 3x^2 - 4", "answer=y = (3x^3 - 4x)/x", "input=y = 3x^2 - 4"), - Iteration( - "y^2 * y^−1 = -12x^2!=y = 3x^2 - 4", "answer=y^2 * y^−1 = -12x^2", "input=y = 3x^2 - 4" - ), - Iteration("y^2/y = 3x^2 - 4!=y = 3x^2 - 4", "answer=y^2/y = 3x^2 - 4", "input=y = 3x^2 - 4"), - Iteration("2 − 3 = -4!=y = 3x^2 - 4", "answer=2 − 3 = -4", "input=y = 3x^2 - 4"), - Iteration("y = 3x^2 + 4!=y = 3x^2 - 4", "answer=y = 3x^2 + 4", "input=y = 3x^2 - 4"), - Iteration("y - 4 = 3x^2!=y = 3x^2 - 4", "answer=y - 4 = 3x^2", "input=y = 3x^2 - 4"), - Iteration("y − 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y − 3x^2 - 4 = 0", "input=y = 3x^2 - 4"), - Iteration("0 = y + 3x^2 - 4!=y = 3x^2 - 4", "answer=0 = y + 3x^2 - 4", "input=y = 3x^2 - 4"), - Iteration("2 = 0!=y = 3x^2 - 4", "answer=2 = 0", "input=y = 3x^2 - 4"), - Iteration("y - x^2 = -4!=y = 3x^2 - 4", "answer=y - x^2 = -4", "input=y = 3x^2 - 4"), - Iteration("y=3x-4!=y = 3x^2 - 4", "answer=y=3x-4", "input=y = 3x^2 - 4"), - Iteration("y/sqrt(2)=x!=y=sqrt(2)x", "answer=y/sqrt(2)=x", "input=y=sqrt(2)x"), - Iteration("y/4=x!=y=4x", "answer=y/4=x", "input=y=4x"), - Iteration("y/4=16x!=y=4x", "answer=y/4=16x", "input=y=4x"), - Iteration("xy=x^2!=y=x", "answer=xy=x^2", "input=y=x") + @Iteration("y = -4 + 3x^2!=y = 3x^2 - 4", "answer=y = -4 + 3x^2", "input=y = 3x^2 - 4") + @Iteration("y = x^2*3 - 4!=y = 3x^2 - 4", "answer=y = x^2*3 - 4", "input=y = 3x^2 - 4") + @Iteration("y+4=3x^2!=y = 3x^2 - 4", "answer=y+4=3x^2", "input=y = 3x^2 - 4") + @Iteration("y-3x^2=-4!=y = 3x^2 - 4", "answer=y-3x^2=-4", "input=y = 3x^2 - 4") + @Iteration("-4=y-3x^2!=y = 3x^2 - 4", "answer=-4=y-3x^2", "input=y = 3x^2 - 4") + @Iteration("3x^2-y=4!=y = 3x^2 - 4", "answer=3x^2-y=4", "input=y = 3x^2 - 4") + @Iteration("3x^2=4+y!=y = 3x^2 - 4", "answer=3x^2=4+y", "input=y = 3x^2 - 4") + @Iteration("y-x^2=2x^2-4!=y = 3x^2 - 4", "answer=y-x^2=2x^2-4", "input=y = 3x^2 - 4") + @Iteration("y=x*(2^(1/2))!=y=sqrt(2)x", "answer=y=x*(2^(1/2))", "input=y=sqrt(2)x") + @Iteration("y − 3x^2 = -4!=y = 3x^2 - 4", "answer=y − 3x^2 = -4", "input=y = 3x^2 - 4") + @Iteration("3x^2 - 4 = y!=y = 3x^2 - 4", "answer=3x^2 - 4 = y", "input=y = 3x^2 - 4") + @Iteration("y = 3x^2 - 7!=y = 3x^2 - 4", "answer=y = 3x^2 - 7", "input=y = 3x^2 - 4") + @Iteration("x^2 = 3y - 4!=y = 3x^2 - 4", "answer=x^2 = 3y - 4", "input=y = 3x^2 - 4") + @Iteration("y/(3x^2 - 4) = 1!=y = 3x^2 - 4", "answer=y/(3x^2 - 4) = 1", "input=y = 3x^2 - 4") + @Iteration("y + 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y + 3x^2 - 4 = 0", "input=y = 3x^2 - 4") + @Iteration("y − 3x^2 + 4 = 0!=y = 3x^2 - 4", "answer=y − 3x^2 + 4 = 0", "input=y = 3x^2 - 4") + @Iteration("y^2 = 3x^2y - 4y!=y = 3x^2 - 4", "answer=y^2 = 3x^2y - 4y", "input=y = 3x^2 - 4") + @Iteration("y = (3x^3 - 4x)/x!=y = 3x^2 - 4", "answer=y = (3x^3 - 4x)/x", "input=y = 3x^2 - 4") + @Iteration( + "y^2 * y^−1 = -12x^2!=y = 3x^2 - 4", "answer=y^2 * y^−1 = -12x^2", "input=y = 3x^2 - 4" ) + @Iteration("y^2/y = 3x^2 - 4!=y = 3x^2 - 4", "answer=y^2/y = 3x^2 - 4", "input=y = 3x^2 - 4") + @Iteration("2 − 3 = -4!=y = 3x^2 - 4", "answer=2 − 3 = -4", "input=y = 3x^2 - 4") + @Iteration("y = 3x^2 + 4!=y = 3x^2 - 4", "answer=y = 3x^2 + 4", "input=y = 3x^2 - 4") + @Iteration("y - 4 = 3x^2!=y = 3x^2 - 4", "answer=y - 4 = 3x^2", "input=y = 3x^2 - 4") + @Iteration("y − 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y − 3x^2 - 4 = 0", "input=y = 3x^2 - 4") + @Iteration("0 = y + 3x^2 - 4!=y = 3x^2 - 4", "answer=0 = y + 3x^2 - 4", "input=y = 3x^2 - 4") + @Iteration("2 = 0!=y = 3x^2 - 4", "answer=2 = 0", "input=y = 3x^2 - 4") + @Iteration("y - x^2 = -4!=y = 3x^2 - 4", "answer=y - x^2 = -4", "input=y = 3x^2 - 4") + @Iteration("y=3x-4!=y = 3x^2 - 4", "answer=y=3x-4", "input=y = 3x^2 - 4") + @Iteration("y/sqrt(2)=x!=y=sqrt(2)x", "answer=y/sqrt(2)=x", "input=y=sqrt(2)x") + @Iteration("y/4=x!=y=4x", "answer=y/4=x", "input=y=4x") + @Iteration("y/4=16x!=y=4x", "answer=y/4=16x", "input=y=4x") + @Iteration("xy=x^2!=y=x", "answer=xy=x^2", "input=y=x") fun testMatches_assortedExpressions_withoutMatchingCharacteristics_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt index 9af344ecb91..9a3d9d24c05 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/mathequationinput/MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt @@ -19,7 +19,6 @@ import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -63,10 +62,8 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("y=1!=y=1", "answer=y=1", "input=y=1"), - Iteration("1=y!=1=y", "answer=1=y", "input=1=y") - ) + @Iteration("y=1!=y=1", "answer=y=1", "input=y=1") + @Iteration("1=y!=1=y", "answer=1=y", "input=1=y") fun testMatches_answerHasDisallowedVariable_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -80,15 +77,13 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("0=1==0=1", "answer=0=1", "input=0=1"), - Iteration("y=0==y=0", "answer=y=0", "input=y=0"), - Iteration("y=1==y=1", "answer=y=1", "input=y=1"), - Iteration("0=y==0=y", "answer=0=y", "input=0=y"), - Iteration("1=y==1=y", "answer=1=y", "input=1=y"), - Iteration("y=x==y=x", "answer=y=x", "input=y=x"), - Iteration("x=y==x=y", "answer=x=y", "input=x=y") - ) + @Iteration("0=1==0=1", "answer=0=1", "input=0=1") + @Iteration("y=0==y=0", "answer=y=0", "input=y=0") + @Iteration("y=1==y=1", "answer=y=1", "input=y=1") + @Iteration("0=y==0=y", "answer=0=y", "input=0=y") + @Iteration("1=y==1=y", "answer=1=y", "input=1=y") + @Iteration("y=x==y=x", "answer=y=x", "input=y=x") + @Iteration("x=y==x=y", "answer=x=y", "input=x=y") fun testMatches_sameSingleTerms_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -100,16 +95,14 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("y=-x==y=-x", "answer=y=-x", "input=y=-x"), - Iteration("-y=x==-y=x", "answer=-y=x", "input=-y=x"), - Iteration("y=3.14+x==y=3.14+x", "answer=y=3.14+x", "input=y=3.14+x"), - Iteration("y=x+y+z==y=x+y+z", "answer=y=x+y+z", "input=y=x+y+z"), - Iteration("y=x/y/z==y=x/y/z", "answer=y=x/y/z", "input=y=x/y/z"), - Iteration("y=x/2/3==y=x/2/3", "answer=y=x/2/3", "input=y=x/2/3"), - Iteration("y=x^2==y=x^2", "answer=y=x^2", "input=y=x^2"), - Iteration("y=sqrt(x)==y=sqrt(x)", "answer=y=sqrt(x)", "input=y=sqrt(x)") - ) + @Iteration("y=-x==y=-x", "answer=y=-x", "input=y=-x") + @Iteration("-y=x==-y=x", "answer=-y=x", "input=-y=x") + @Iteration("y=3.14+x==y=3.14+x", "answer=y=3.14+x", "input=y=3.14+x") + @Iteration("y=x+y+z==y=x+y+z", "answer=y=x+y+z", "input=y=x+y+z") + @Iteration("y=x/y/z==y=x/y/z", "answer=y=x/y/z", "input=y=x/y/z") + @Iteration("y=x/2/3==y=x/2/3", "answer=y=x/2/3", "input=y=x/2/3") + @Iteration("y=x^2==y=x^2", "answer=y=x^2", "input=y=x^2") + @Iteration("y=sqrt(x)==y=sqrt(x)", "answer=y=sqrt(x)", "input=y=sqrt(x)") fun testMatches_sameSingleOperations_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -121,17 +114,15 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("y=1!=y=0", "answer=y=1", "input=y=0"), - Iteration("y=0!=y=1", "answer=y=0", "input=y=1"), - Iteration("y=3.14!=y=1", "answer=y=3.14", "input=y=1"), - Iteration("y=1!=y=3.14", "answer=y=1", "input=y=3.14"), - Iteration("y=x!=y=3.14", "answer=y=x", "input=y=3.14"), - Iteration("y=1!=y=x", "answer=y=1", "input=y=x"), - Iteration("y=3.14!=y=x", "answer=y=3.14", "input=y=x"), - Iteration("y=z!=y=x", "answer=y=z", "input=y=x"), - Iteration("y=x!=y=z", "answer=y=x", "input=y=z") - ) + @Iteration("y=1!=y=0", "answer=y=1", "input=y=0") + @Iteration("y=0!=y=1", "answer=y=0", "input=y=1") + @Iteration("y=3.14!=y=1", "answer=y=3.14", "input=y=1") + @Iteration("y=1!=y=3.14", "answer=y=1", "input=y=3.14") + @Iteration("y=x!=y=3.14", "answer=y=x", "input=y=3.14") + @Iteration("y=1!=y=x", "answer=y=1", "input=y=x") + @Iteration("y=3.14!=y=x", "answer=y=3.14", "input=y=x") + @Iteration("y=z!=y=x", "answer=y=z", "input=y=x") + @Iteration("y=x!=y=z", "answer=y=x", "input=y=z") fun testMatches_differentSingleTerms_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -144,20 +135,18 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("y=1+x==y=x+1", "answer=y=1+x", "input=y=x+1"), - Iteration("y=z+x==y=x+z", "answer=y=z+x", "input=y=x+z"), - Iteration("y+1=x==1+y=x", "answer=y+1=x", "input=1+y=x"), - Iteration("y+z=x==z+y=x", "answer=y+z=x", "input=z+y=x"), - Iteration("x+y=1+z==y+x=z+1", "answer=x+y=1+z", "input=y+x=z+1"), - Iteration("y=-x+1==y=1-x", "answer=y=-x+1", "input=y=1-x"), - Iteration("-y+x=z==x-y=z", "answer=-y+x=z", "input=x-y=z"), - Iteration("y=x*2==y=2x", "answer=y=x*2", "input=y=2x"), - Iteration("y*2=z==2y=z", "answer=y*2=z", "input=2y=z"), - Iteration("y=3*2==y=2*3", "answer=y=3*2", "input=y=2*3"), - Iteration("y=zx==y=xz", "answer=y=zx", "input=y=xz"), - Iteration("yx=z==xy=z", "answer=yx=z", "input=xy=z") - ) + @Iteration("y=1+x==y=x+1", "answer=y=1+x", "input=y=x+1") + @Iteration("y=z+x==y=x+z", "answer=y=z+x", "input=y=x+z") + @Iteration("y+1=x==1+y=x", "answer=y+1=x", "input=1+y=x") + @Iteration("y+z=x==z+y=x", "answer=y+z=x", "input=z+y=x") + @Iteration("x+y=1+z==y+x=z+1", "answer=x+y=1+z", "input=y+x=z+1") + @Iteration("y=-x+1==y=1-x", "answer=y=-x+1", "input=y=1-x") + @Iteration("-y+x=z==x-y=z", "answer=-y+x=z", "input=x-y=z") + @Iteration("y=x*2==y=2x", "answer=y=x*2", "input=y=2x") + @Iteration("y*2=z==2y=z", "answer=y*2=z", "input=2y=z") + @Iteration("y=3*2==y=2*3", "answer=y=3*2", "input=y=2*3") + @Iteration("y=zx==y=xz", "answer=y=zx", "input=y=xz") + @Iteration("yx=z==xy=z", "answer=yx=z", "input=xy=z") fun testMatches_operationsDiffer_byCommutativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -169,20 +158,18 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("y=1+(2+3)==y=(1+2)+3", "answer=y=1+(2+3)", "input=y=(1+2)+3"), - Iteration("y=x+(y+z)==y=(x+y)+z", "answer=y=x+(y+z)", "input=y=(x+y)+z"), - Iteration("x+(y+z)=1==(x+y)+z=1", "answer=x+(y+z)=1", "input=(x+y)+z=1"), - Iteration( - "(x+y)+z=1+(2+3)==x+(y+z)=(1+2)+3", "answer=(x+y)+z=1+(2+3)", "input=x+(y+z)=(1+2)+3" - ), - Iteration("y=2*(3*4)==y=(2*3)*4", "answer=y=2*(3*4)", "input=y=(2*3)*4"), - Iteration("y=2*(3x)==y=(2x)*3", "answer=y=2*(3x)", "input=y=(2x)*3"), - Iteration("y=x(yz)==y=(xy)z", "answer=y=x(yz)", "input=y=(xy)z"), - Iteration("x(yz)=2==(xy)z=2", "answer=x(yz)=2", "input=(xy)z=2"), - Iteration("2*(3y)=4==(2y)*3=4", "answer=2*(3y)=4", "input=(2y)*3=4"), - Iteration("x(yz)=(2*3)*4==(xy)z=2*(3*4)", "answer=x(yz)=(2*3)*4", "input=(xy)z=2*(3*4)") + @Iteration("y=1+(2+3)==y=(1+2)+3", "answer=y=1+(2+3)", "input=y=(1+2)+3") + @Iteration("y=x+(y+z)==y=(x+y)+z", "answer=y=x+(y+z)", "input=y=(x+y)+z") + @Iteration("x+(y+z)=1==(x+y)+z=1", "answer=x+(y+z)=1", "input=(x+y)+z=1") + @Iteration( + "(x+y)+z=1+(2+3)==x+(y+z)=(1+2)+3", "answer=(x+y)+z=1+(2+3)", "input=x+(y+z)=(1+2)+3" ) + @Iteration("y=2*(3*4)==y=(2*3)*4", "answer=y=2*(3*4)", "input=y=(2*3)*4") + @Iteration("y=2*(3x)==y=(2x)*3", "answer=y=2*(3x)", "input=y=(2x)*3") + @Iteration("y=x(yz)==y=(xy)z", "answer=y=x(yz)", "input=y=(xy)z") + @Iteration("x(yz)=2==(xy)z=2", "answer=x(yz)=2", "input=(xy)z=2") + @Iteration("2*(3y)=4==(2y)*3=4", "answer=2*(3y)=4", "input=(2y)*3=4") + @Iteration("x(yz)=(2*3)*4==(xy)z=2*(3*4)", "answer=x(yz)=(2*3)*4", "input=(xy)z=2*(3*4)") fun testMatches_operationsDiffer_byAssociativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -194,18 +181,16 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("y=3.14-1!=y=1-3.14", "answer=y=3.14-1", "input=y=1-3.14"), - Iteration("y=1-(2-3)!=y=(1-2)-3", "answer=y=1-(2-3)", "input=y=(1-2)-3"), - Iteration("y-1=3!=1-y=3", "answer=y-1=3", "input=1-y=3"), - Iteration("x-(y-z)=3!=(x-y)-z=3", "answer=x-(y-z)=3", "input=(x-y)-z=3"), - Iteration("y=3.14/x!=y=x/3.14", "answer=y=3.14/x", "input=y=x/3.14"), - Iteration("y/x=2!=x/y=2", "answer=y/x=2", "input=x/y=2"), - Iteration("y=3.14^2!=y=2^3.14", "answer=y=3.14^2", "input=y=2^3.14"), - Iteration("(3.14^2)y=2!=(2^3.14)y=2", "answer=(3.14^2)y=2", "input=(2^3.14)y=2"), - Iteration("y=x/(y/z)!=y=(x/y)/z", "answer=y=x/(y/z)", "input=y=(x/y)/z"), - Iteration("x/(y/z)=2!=(x/y)/z=2", "answer=x/(y/z)=2", "input=(x/y)/z=2") - ) + @Iteration("y=3.14-1!=y=1-3.14", "answer=y=3.14-1", "input=y=1-3.14") + @Iteration("y=1-(2-3)!=y=(1-2)-3", "answer=y=1-(2-3)", "input=y=(1-2)-3") + @Iteration("y-1=3!=1-y=3", "answer=y-1=3", "input=1-y=3") + @Iteration("x-(y-z)=3!=(x-y)-z=3", "answer=x-(y-z)=3", "input=(x-y)-z=3") + @Iteration("y=3.14/x!=y=x/3.14", "answer=y=3.14/x", "input=y=x/3.14") + @Iteration("y/x=2!=x/y=2", "answer=y/x=2", "input=x/y=2") + @Iteration("y=3.14^2!=y=2^3.14", "answer=y=3.14^2", "input=y=2^3.14") + @Iteration("(3.14^2)y=2!=(2^3.14)y=2", "answer=(3.14^2)y=2", "input=(2^3.14)y=2") + @Iteration("y=x/(y/z)!=y=(x/y)/z", "answer=y=x/(y/z)", "input=y=(x/y)/z") + @Iteration("x/(y/z)=2!=(x/y)/z=2", "answer=x/(y/z)=2", "input=(x/y)/z=2") fun testMatches_operationsDiffer_byNonCommutativeOrAssociativeReordering_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -218,10 +203,8 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("y=1+2==y=1-(-2)", "answer=y=1+2", "input=y=1-(-2)"), - Iteration("y=1+x==y=1-(-x)", "answer=y=1+x", "input=y=1-(-x)") - ) + @Iteration("y=1+2==y=1-(-2)", "answer=y=1+2", "input=y=1-(-2)") + @Iteration("y=1+x==y=1-(-x)", "answer=y=1+x", "input=y=1-(-x)") fun testMatches_operationsDiffer_byDistributingNegation_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -233,28 +216,26 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("y=1-2!=y=-(2-1)", "answer=y=1-2", "input=y=-(2-1)"), - Iteration("z=x-y!=z=-(y-x)", "answer=z=x-y", "input=z=-(y-x)"), - Iteration("y=1+2!=y=1+1+1", "answer=y=1+2", "input=y=1+1+1"), - Iteration("y=4-6!=y=1-2-1", "answer=y=4-6", "input=y=1-2-1"), - Iteration("y=2*3*2*2!=y=2*3*4", "answer=y=2*3*2*2", "input=y=2*3*4"), - Iteration("y=-6-2!=y=2*-(3+1)", "answer=y=-6-2", "input=y=2*-(3+1)"), - Iteration("y=2/3/2/2!=y=2/3/4", "answer=y=2/3/2/2", "input=y=2/3/4"), - Iteration("y=2^(2+1)!=y=2^3", "answer=y=2^(2+1)", "input=y=2^3"), - Iteration("y=2^(-1)!=y=1/2", "answer=y=2^(-1)", "input=y=1/2"), - Iteration("y=2+x!=y=1+x+1", "answer=y=2+x", "input=y=1+x+1"), - Iteration("y=-x!=y=1-x-1", "answer=y=-x", "input=y=1-x-1"), - Iteration("y=4x!=y=2*2*x", "answer=y=4x", "input=y=2*2*x"), - Iteration("y=2-6x!=y=2*(-3x+1)", "answer=y=2-6x", "input=y=2*(-3x+1)"), - Iteration("y=x/4!=y=x/2/2", "answer=y=x/4", "input=y=x/2/2"), - Iteration("y=x^(2+1)!=y=x^3", "answer=y=x^(2+1)", "input=y=x^3"), - Iteration("y=x*(2^(-1))!=y=x/2", "answer=y=x*(2^(-1))", "input=y=x/2"), - Iteration("y+2=x!=1+1+y=x", "answer=y+2=x", "input=1+1+y=x"), - Iteration("(2^2)y=x+2!=4y=x+2", "answer=(2^2)y=x+2", "input=4y=x+2"), - Iteration("y^(4-2)=3x!=y^2=3x", "answer=y^(4-2)=3x", "input=y^2=3x"), - Iteration("y/2/2=3x!=y/4=3x", "answer=y/2/2=3x", "input=y/4=3x") - ) + @Iteration("y=1-2!=y=-(2-1)", "answer=y=1-2", "input=y=-(2-1)") + @Iteration("z=x-y!=z=-(y-x)", "answer=z=x-y", "input=z=-(y-x)") + @Iteration("y=1+2!=y=1+1+1", "answer=y=1+2", "input=y=1+1+1") + @Iteration("y=4-6!=y=1-2-1", "answer=y=4-6", "input=y=1-2-1") + @Iteration("y=2*3*2*2!=y=2*3*4", "answer=y=2*3*2*2", "input=y=2*3*4") + @Iteration("y=-6-2!=y=2*-(3+1)", "answer=y=-6-2", "input=y=2*-(3+1)") + @Iteration("y=2/3/2/2!=y=2/3/4", "answer=y=2/3/2/2", "input=y=2/3/4") + @Iteration("y=2^(2+1)!=y=2^3", "answer=y=2^(2+1)", "input=y=2^3") + @Iteration("y=2^(-1)!=y=1/2", "answer=y=2^(-1)", "input=y=1/2") + @Iteration("y=2+x!=y=1+x+1", "answer=y=2+x", "input=y=1+x+1") + @Iteration("y=-x!=y=1-x-1", "answer=y=-x", "input=y=1-x-1") + @Iteration("y=4x!=y=2*2*x", "answer=y=4x", "input=y=2*2*x") + @Iteration("y=2-6x!=y=2*(-3x+1)", "answer=y=2-6x", "input=y=2*(-3x+1)") + @Iteration("y=x/4!=y=x/2/2", "answer=y=x/4", "input=y=x/2/2") + @Iteration("y=x^(2+1)!=y=x^3", "answer=y=x^(2+1)", "input=y=x^3") + @Iteration("y=x*(2^(-1))!=y=x/2", "answer=y=x*(2^(-1))", "input=y=x/2") + @Iteration("y+2=x!=1+1+y=x", "answer=y+2=x", "input=1+1+y=x") + @Iteration("(2^2)y=x+2!=4y=x+2", "answer=(2^2)y=x+2", "input=4y=x+2") + @Iteration("y^(4-2)=3x!=y^2=3x", "answer=y^(4-2)=3x", "input=y^2=3x") + @Iteration("y/2/2=3x!=y/4=3x", "answer=y/2/2=3x", "input=y/4=3x") fun testMatches_operationsDiffer_byDistributionAndCombining_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -266,13 +247,11 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("2+x=y!=y=2+x", "answer=2+x=y", "input=y=2+x"), - Iteration("-3x^3=2y^2!=2y^2=-3x^3", "answer=-3x^3=2y^2", "input=2y^2=-3x^3"), - Iteration("-4+x=2+y+1-1!=2+y=x-4", "answer=-4+x=2+y+1-1", "input=2+y=x-4"), - Iteration("y=x-6!=2+y=x-4", "answer=y=x-6", "input=2+y=x-4"), - Iteration("(1+1+1)*x=2*y/4!=y/2=3x", "answer=(1+1+1)*x=2*y/4", "input=y/2=3x") - ) + @Iteration("2+x=y!=y=2+x", "answer=2+x=y", "input=y=2+x") + @Iteration("-3x^3=2y^2!=2y^2=-3x^3", "answer=-3x^3=2y^2", "input=2y^2=-3x^3") + @Iteration("-4+x=2+y+1-1!=2+y=x-4", "answer=-4+x=2+y+1-1", "input=2+y=x-4") + @Iteration("y=x-6!=2+y=x-4", "answer=y=x-6", "input=2+y=x-4") + @Iteration("(1+1+1)*x=2*y/4!=y/2=3x", "answer=(1+1+1)*x=2*y/4", "input=y/2=3x") fun testMatches_sidesRearrangedAroundEqualsSign_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -284,11 +263,9 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("y = 3x^2 - 4==y = 3x^2 - 4", "answer=y = 3x^2 - 4", "input=y = 3x^2 - 4"), - Iteration("y = -4 + 3x^2==y = 3x^2 - 4", "answer=y = -4 + 3x^2", "input=y = 3x^2 - 4"), - Iteration("y = x^2*3 - 4==y = 3x^2 - 4", "answer=y = x^2*3 - 4", "input=y = 3x^2 - 4") - ) + @Iteration("y = 3x^2 - 4==y = 3x^2 - 4", "answer=y = 3x^2 - 4", "input=y = 3x^2 - 4") + @Iteration("y = -4 + 3x^2==y = 3x^2 - 4", "answer=y = -4 + 3x^2", "input=y = 3x^2 - 4") + @Iteration("y = x^2*3 - 4==y = 3x^2 - 4", "answer=y = x^2*3 - 4", "input=y = 3x^2 - 4") fun testMatches_assortedExpressions_withMatchingCharacteristics_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -301,40 +278,38 @@ class MathEquationInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest } @Test - @RunParameterized( - Iteration("y+4=3x^2!=y = 3x^2 - 4", "answer=y+4=3x^2", "input=y = 3x^2 - 4"), - Iteration("y-3x^2=-4!=y = 3x^2 - 4", "answer=y-3x^2=-4", "input=y = 3x^2 - 4"), - Iteration("-4=y-3x^2!=y = 3x^2 - 4", "answer=-4=y-3x^2", "input=y = 3x^2 - 4"), - Iteration("3x^2-y=4!=y = 3x^2 - 4", "answer=3x^2-y=4", "input=y = 3x^2 - 4"), - Iteration("3x^2=4+y!=y = 3x^2 - 4", "answer=3x^2=4+y", "input=y = 3x^2 - 4"), - Iteration("y-x^2=2x^2-4!=y = 3x^2 - 4", "answer=y-x^2=2x^2-4", "input=y = 3x^2 - 4"), - Iteration("y=x*(2^(1/2))!=y=sqrt(2)x", "answer=y=x*(2^(1/2))", "input=y=sqrt(2)x"), - Iteration("y − 3x^2 = -4!=y = 3x^2 - 4", "answer=y − 3x^2 = -4", "input=y = 3x^2 - 4"), - Iteration("3x^2 - 4 = y!=y = 3x^2 - 4", "answer=3x^2 - 4 = y", "input=y = 3x^2 - 4"), - Iteration("y = 3x^2 - 7!=y = 3x^2 - 4", "answer=y = 3x^2 - 7", "input=y = 3x^2 - 4"), - Iteration("x^2 = 3y - 4!=y = 3x^2 - 4", "answer=x^2 = 3y - 4", "input=y = 3x^2 - 4"), - Iteration("y/(3x^2 - 4) = 1!=y = 3x^2 - 4", "answer=y/(3x^2 - 4) = 1", "input=y = 3x^2 - 4"), - Iteration("y + 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y + 3x^2 - 4 = 0", "input=y = 3x^2 - 4"), - Iteration("y − 3x^2 + 4 = 0!=y = 3x^2 - 4", "answer=y − 3x^2 + 4 = 0", "input=y = 3x^2 - 4"), - Iteration("y^2 = 3x^2y - 4y!=y = 3x^2 - 4", "answer=y^2 = 3x^2y - 4y", "input=y = 3x^2 - 4"), - Iteration("y = (3x^3 - 4x)/x!=y = 3x^2 - 4", "answer=y = (3x^3 - 4x)/x", "input=y = 3x^2 - 4"), - Iteration( - "y^2 * y^−1 = -12x^2!=y = 3x^2 - 4", "answer=y^2 * y^−1 = -12x^2", "input=y = 3x^2 - 4" - ), - Iteration("y^2/y = 3x^2 - 4!=y = 3x^2 - 4", "answer=y^2/y = 3x^2 - 4", "input=y = 3x^2 - 4"), - Iteration("2 − 3 = -4!=y = 3x^2 - 4", "answer=2 − 3 = -4", "input=y = 3x^2 - 4"), - Iteration("y = 3x^2 + 4!=y = 3x^2 - 4", "answer=y = 3x^2 + 4", "input=y = 3x^2 - 4"), - Iteration("y - 4 = 3x^2!=y = 3x^2 - 4", "answer=y - 4 = 3x^2", "input=y = 3x^2 - 4"), - Iteration("y − 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y − 3x^2 - 4 = 0", "input=y = 3x^2 - 4"), - Iteration("0 = y + 3x^2 - 4!=y = 3x^2 - 4", "answer=0 = y + 3x^2 - 4", "input=y = 3x^2 - 4"), - Iteration("2 = 0!=y = 3x^2 - 4", "answer=2 = 0", "input=y = 3x^2 - 4"), - Iteration("y - x^2 = -4!=y = 3x^2 - 4", "answer=y - x^2 = -4", "input=y = 3x^2 - 4"), - Iteration("y=3x-4!=y = 3x^2 - 4", "answer=y=3x-4", "input=y = 3x^2 - 4"), - Iteration("y/sqrt(2)=x!=y=sqrt(2)x", "answer=y/sqrt(2)=x", "input=y=sqrt(2)x"), - Iteration("y/4=x!=y=4x", "answer=y/4=x", "input=y=4x"), - Iteration("y/4=16x!=y=4x", "answer=y/4=16x", "input=y=4x"), - Iteration("xy=x^2!=y=x", "answer=xy=x^2", "input=y=x") + @Iteration("y+4=3x^2!=y = 3x^2 - 4", "answer=y+4=3x^2", "input=y = 3x^2 - 4") + @Iteration("y-3x^2=-4!=y = 3x^2 - 4", "answer=y-3x^2=-4", "input=y = 3x^2 - 4") + @Iteration("-4=y-3x^2!=y = 3x^2 - 4", "answer=-4=y-3x^2", "input=y = 3x^2 - 4") + @Iteration("3x^2-y=4!=y = 3x^2 - 4", "answer=3x^2-y=4", "input=y = 3x^2 - 4") + @Iteration("3x^2=4+y!=y = 3x^2 - 4", "answer=3x^2=4+y", "input=y = 3x^2 - 4") + @Iteration("y-x^2=2x^2-4!=y = 3x^2 - 4", "answer=y-x^2=2x^2-4", "input=y = 3x^2 - 4") + @Iteration("y=x*(2^(1/2))!=y=sqrt(2)x", "answer=y=x*(2^(1/2))", "input=y=sqrt(2)x") + @Iteration("y − 3x^2 = -4!=y = 3x^2 - 4", "answer=y − 3x^2 = -4", "input=y = 3x^2 - 4") + @Iteration("3x^2 - 4 = y!=y = 3x^2 - 4", "answer=3x^2 - 4 = y", "input=y = 3x^2 - 4") + @Iteration("y = 3x^2 - 7!=y = 3x^2 - 4", "answer=y = 3x^2 - 7", "input=y = 3x^2 - 4") + @Iteration("x^2 = 3y - 4!=y = 3x^2 - 4", "answer=x^2 = 3y - 4", "input=y = 3x^2 - 4") + @Iteration("y/(3x^2 - 4) = 1!=y = 3x^2 - 4", "answer=y/(3x^2 - 4) = 1", "input=y = 3x^2 - 4") + @Iteration("y + 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y + 3x^2 - 4 = 0", "input=y = 3x^2 - 4") + @Iteration("y − 3x^2 + 4 = 0!=y = 3x^2 - 4", "answer=y − 3x^2 + 4 = 0", "input=y = 3x^2 - 4") + @Iteration("y^2 = 3x^2y - 4y!=y = 3x^2 - 4", "answer=y^2 = 3x^2y - 4y", "input=y = 3x^2 - 4") + @Iteration("y = (3x^3 - 4x)/x!=y = 3x^2 - 4", "answer=y = (3x^3 - 4x)/x", "input=y = 3x^2 - 4") + @Iteration( + "y^2 * y^−1 = -12x^2!=y = 3x^2 - 4", "answer=y^2 * y^−1 = -12x^2", "input=y = 3x^2 - 4" ) + @Iteration("y^2/y = 3x^2 - 4!=y = 3x^2 - 4", "answer=y^2/y = 3x^2 - 4", "input=y = 3x^2 - 4") + @Iteration("2 − 3 = -4!=y = 3x^2 - 4", "answer=2 − 3 = -4", "input=y = 3x^2 - 4") + @Iteration("y = 3x^2 + 4!=y = 3x^2 - 4", "answer=y = 3x^2 + 4", "input=y = 3x^2 - 4") + @Iteration("y - 4 = 3x^2!=y = 3x^2 - 4", "answer=y - 4 = 3x^2", "input=y = 3x^2 - 4") + @Iteration("y − 3x^2 - 4 = 0!=y = 3x^2 - 4", "answer=y − 3x^2 - 4 = 0", "input=y = 3x^2 - 4") + @Iteration("0 = y + 3x^2 - 4!=y = 3x^2 - 4", "answer=0 = y + 3x^2 - 4", "input=y = 3x^2 - 4") + @Iteration("2 = 0!=y = 3x^2 - 4", "answer=2 = 0", "input=y = 3x^2 - 4") + @Iteration("y - x^2 = -4!=y = 3x^2 - 4", "answer=y - x^2 = -4", "input=y = 3x^2 - 4") + @Iteration("y=3x-4!=y = 3x^2 - 4", "answer=y=3x-4", "input=y = 3x^2 - 4") + @Iteration("y/sqrt(2)=x!=y=sqrt(2)x", "answer=y/sqrt(2)=x", "input=y=sqrt(2)x") + @Iteration("y/4=x!=y=4x", "answer=y/4=x", "input=y=4x") + @Iteration("y/4=16x!=y=4x", "answer=y/4=16x", "input=y=4x") + @Iteration("xy=x^2!=y=x", "answer=xy=x^2", "input=y=x") fun testMatches_assortedExpressions_withoutMatchingCharacteristics_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputIsEquivalentToRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputIsEquivalentToRuleClassifierProviderTest.kt index 611fcb04b04..7a0f3a1b6c2 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputIsEquivalentToRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputIsEquivalentToRuleClassifierProviderTest.kt @@ -17,7 +17,6 @@ import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -59,11 +58,9 @@ class NumericExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("0==0", "answer=0", "input=0"), - Iteration("1==1", "answer=1", "input=1"), - Iteration("2==2", "answer=2", "input=2") - ) + @Iteration("0==0", "answer=0", "input=0") + @Iteration("1==1", "answer=1", "input=1") + @Iteration("2==2", "answer=2", "input=2") fun testMatches_sameSingleTerms_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -75,19 +72,17 @@ class NumericExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("-2==-2", "answer=-2", "input=-2"), - Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14"), - Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14"), - Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3"), - Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14"), - Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14"), - Iteration("2/3==2/3", "answer=2/3", "input=2/3"), - Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14"), - Iteration("2^3==2^3", "answer=2^3", "input=2^3"), - Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14"), - Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)") - ) + @Iteration("-2==-2", "answer=-2", "input=-2") + @Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14") + @Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14") + @Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3") + @Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14") + @Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14") + @Iteration("2/3==2/3", "answer=2/3", "input=2/3") + @Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14") + @Iteration("2^3==2^3", "answer=2^3", "input=2^3") + @Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14") + @Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)") fun testMatches_sameSingleOperations_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -99,12 +94,10 @@ class NumericExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1!=0", "answer=1", "input=0"), - Iteration("0!=1", "answer=0", "input=1"), - Iteration("3.14!=1", "answer=3.14", "input=1"), - Iteration("1!=3.14", "answer=1", "input=3.14") - ) + @Iteration("1!=0", "answer=1", "input=0") + @Iteration("0!=1", "answer=0", "input=1") + @Iteration("3.14!=1", "answer=3.14", "input=1") + @Iteration("1!=3.14", "answer=1", "input=3.14") fun testMatches_differentSingleTerms_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -116,12 +109,10 @@ class NumericExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("3.14+1==1+3.14", "answer=3.14+1", "input=1+3.14"), - Iteration("3+2+1==1+2+3", "answer=3+2+1", "input=1+2+3"), - Iteration("-3.14+1==1-3.14", "answer=-3.14+1", "input=1-3.14"), - Iteration("3.14*2==2*3.14", "answer=3.14*2", "input=2*3.14") - ) + @Iteration("3.14+1==1+3.14", "answer=3.14+1", "input=1+3.14") + @Iteration("3+2+1==1+2+3", "answer=3+2+1", "input=1+2+3") + @Iteration("-3.14+1==1-3.14", "answer=-3.14+1", "input=1-3.14") + @Iteration("3.14*2==2*3.14", "answer=3.14*2", "input=2*3.14") fun testMatches_operationsDiffer_byCommutativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -133,10 +124,8 @@ class NumericExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1+(2+3)==(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3"), - Iteration("2*(3*4)==(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4") - ) + @Iteration("1+(2+3)==(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3") + @Iteration("2*(3*4)==(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4") fun testMatches_operationsDiffer_byAssociativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -148,17 +137,15 @@ class NumericExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14"), - Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3"), - Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14"), - Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4"), - Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14"), - Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14"), - Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z"), - Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14"), - Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") - ) + @Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14") + @Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3") + @Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14") + @Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4") + @Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14") + @Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14") + @Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z") + @Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14") + @Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") fun testMatches_operationsDiffer_byNonCommutativeOrAssociativeReordering_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -171,17 +158,15 @@ class NumericExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1-2==-(2-1)", "answer=1-2", "input=-(2-1)"), - Iteration("1+2==1+1+1", "answer=1+2", "input=1+1+1"), - Iteration("1+2==1-(-2)", "answer=1+2", "input=1-(-2)"), - Iteration("4-6==1-2-1", "answer=4-6", "input=1-2-1"), - Iteration("2*3*2*2==2*3*4", "answer=2*3*2*2", "input=2*3*4"), - Iteration("-6-2==2*-(3+1)", "answer=-6-2", "input=2*-(3+1)"), - Iteration("2/3/2/2==2/3/4", "answer=2/3/2/2", "input=2/3/4"), - Iteration("2^(2+1)==2^3", "answer=2^(2+1)", "input=2^3"), - Iteration("2^(-1)==1/2", "answer=2^(-1)", "input=1/2") - ) + @Iteration("1-2==-(2-1)", "answer=1-2", "input=-(2-1)") + @Iteration("1+2==1+1+1", "answer=1+2", "input=1+1+1") + @Iteration("1+2==1-(-2)", "answer=1+2", "input=1-(-2)") + @Iteration("4-6==1-2-1", "answer=4-6", "input=1-2-1") + @Iteration("2*3*2*2==2*3*4", "answer=2*3*2*2", "input=2*3*4") + @Iteration("-6-2==2*-(3+1)", "answer=-6-2", "input=2*-(3+1)") + @Iteration("2/3/2/2==2/3/4", "answer=2/3/2/2", "input=2/3/4") + @Iteration("2^(2+1)==2^3", "answer=2^(2+1)", "input=2^3") + @Iteration("2^(-1)==1/2", "answer=2^(-1)", "input=1/2") fun testMatches_operationsDiffer_byDistributionAndCombining_returnTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -193,112 +178,110 @@ class NumericExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration( - "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2 × (50 + 150 + 100 + 25) ==(50 + 150 + 100 + 25) × 2", - "answer=2 × (50 + 150 + 100 + 25) ", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration( - "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", - "answer=2 * (50 + 150 + 100 + 25) ", - "input=2 × (50 + 150 + 100 + 25)" - ), - Iteration("2+5==5+2", "answer=2+5", "input=5+2"), - Iteration("5+2==5+2", "answer=5+2", "input=5+2"), - Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)"), - Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)"), - Iteration("− (− 4) + 6==6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)"), - Iteration("10==6 − (− 4)", "answer=10", "input=6 − (− 4)"), - Iteration("6 + 4==6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)"), - Iteration("6 + 2^2==6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)"), - Iteration("3 * 2 − (− 4)==6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)"), - Iteration("100/10==6 − (− 4)", "answer=100/10", "input=6 − (− 4)"), - Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5"), - Iteration("3/(10 * 10^4)==3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5"), - Iteration( - "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "200 + 30 + 4 + 0.5 + 0.06 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "0.06 + 0.5 + 4 + 30 + 200 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1234.56==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "123456/100==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456/100", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "61728/50==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=61728/50", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1234 + 56/100==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234 + 56/100", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1230 + 4.56==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1230 + 4.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration( - "2 * 2 * 3 * 3 * 1==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" - ), - Iteration("2 * 2 * 9==2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3"), - Iteration("4 * 3^2==2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3"), - Iteration("8/2 * 3 * 3==2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration("36==2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3"), - Iteration("sqrt(4-2)==sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)"), - Iteration("2*(6+3+4) + 4==2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)"), - Iteration("2*(2+6+3) + 8==2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)"), - Iteration("(2+6+3+4)*2==2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)"), - Iteration("(2+6+3+4) × 2==2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)"), - Iteration("15 - 12 + 3==15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3"), - Iteration( - "3 - (6 * 2) + 15==15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" - ), - Iteration( - "15 - (2 × 6) + 3==15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2 *(50 + 150) + 2*(100 + 25)==(50 + 150 + 100 + 25) × 2", - "answer=2 *(50 + 150) + 2*(100 + 25)", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration( - "2* ( 25+50+100+150)==(50 + 150 + 100 + 25) × 2", - "answer=2* ( 25+50+100+150)", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration("10^−5 * 3==3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5"), - Iteration("30 * 10^−6==3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5"), - Iteration("0.00003==3 * 10^-5", "answer=0.00003", "input=3 * 10^-5"), - Iteration("3/10^5==3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5"), - Iteration("3 *2 – (− 4)==6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)"), - Iteration("7==5+2", "answer=7", "input=5+2"), - Iteration("3+4==5+2", "answer=3+4", "input=5+2") + @Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration( + "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "2 × (50 + 150 + 100 + 25) ==(50 + 150 + 100 + 25) × 2", + "answer=2 × (50 + 150 + 100 + 25) ", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration( + "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", + "answer=2 * (50 + 150 + 100 + 25) ", + "input=2 × (50 + 150 + 100 + 25)" + ) + @Iteration("2+5==5+2", "answer=2+5", "input=5+2") + @Iteration("5+2==5+2", "answer=5+2", "input=5+2") + @Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)") + @Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)") + @Iteration("− (− 4) + 6==6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)") + @Iteration("10==6 − (− 4)", "answer=10", "input=6 − (− 4)") + @Iteration("6 + 4==6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)") + @Iteration("6 + 2^2==6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)") + @Iteration("3 * 2 − (− 4)==6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)") + @Iteration("100/10==6 − (− 4)", "answer=100/10", "input=6 − (− 4)") + @Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5") + @Iteration("3/(10 * 10^4)==3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5") + @Iteration( + "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "200 + 30 + 4 + 0.5 + 0.06 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "0.06 + 0.5 + 4 + 30 + 200 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" ) + @Iteration( + "1234.56==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "123456/100==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456/100", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "61728/50==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=61728/50", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1234 + 56/100==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234 + 56/100", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1230 + 4.56==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1230 + 4.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration( + "2 * 2 * 3 * 3 * 1==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" + ) + @Iteration("2 * 2 * 9==2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3") + @Iteration("4 * 3^2==2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3") + @Iteration("8/2 * 3 * 3==2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("36==2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3") + @Iteration("sqrt(4-2)==sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)") + @Iteration("2*(6+3+4) + 4==2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)") + @Iteration("2*(2+6+3) + 8==2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)") + @Iteration("(2+6+3+4)*2==2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)") + @Iteration("(2+6+3+4) × 2==2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)") + @Iteration("15 - 12 + 3==15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3") + @Iteration( + "3 - (6 * 2) + 15==15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "15 - (2 × 6) + 3==15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "2 *(50 + 150) + 2*(100 + 25)==(50 + 150 + 100 + 25) × 2", + "answer=2 *(50 + 150) + 2*(100 + 25)", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration( + "2* ( 25+50+100+150)==(50 + 150 + 100 + 25) × 2", + "answer=2* ( 25+50+100+150)", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration("10^−5 * 3==3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5") + @Iteration("30 * 10^−6==3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5") + @Iteration("0.00003==3 * 10^-5", "answer=0.00003", "input=3 * 10^-5") + @Iteration("3/10^5==3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5") + @Iteration("3 *2 – (− 4)==6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)") + @Iteration("7==5+2", "answer=7", "input=5+2") + @Iteration("3+4==5+2", "answer=3+4", "input=5+2") fun testMatches_assortedExpressions_withMatchingCharacteristics_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -311,26 +294,24 @@ class NumericExpressionInputIsEquivalentToRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5"), - Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5"), - Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5"), - Iteration( - "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)"), - Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)"), - Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)"), - Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3"), - Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5") + @Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5") + @Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5") + @Iteration( + "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" ) + @Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)") + @Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)") + @Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)") + @Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3") + @Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3") fun testMatches_assortedExpressions_withoutMatchingCharacteristics_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt index b091adab625..bf48dd05303 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest.kt @@ -17,7 +17,6 @@ import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -60,11 +59,9 @@ class NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("0==0", "answer=0", "input=0"), - Iteration("1==1", "answer=1", "input=1"), - Iteration("2==2", "answer=2", "input=2") - ) + @Iteration("0==0", "answer=0", "input=0") + @Iteration("1==1", "answer=1", "input=1") + @Iteration("2==2", "answer=2", "input=2") fun testMatches_sameSingleTerms_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -76,19 +73,17 @@ class NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("-2==-2", "answer=-2", "input=-2"), - Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14"), - Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14"), - Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3"), - Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14"), - Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14"), - Iteration("2/3==2/3", "answer=2/3", "input=2/3"), - Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14"), - Iteration("2^3==2^3", "answer=2^3", "input=2^3"), - Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14"), - Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)") - ) + @Iteration("-2==-2", "answer=-2", "input=-2") + @Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14") + @Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14") + @Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3") + @Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14") + @Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14") + @Iteration("2/3==2/3", "answer=2/3", "input=2/3") + @Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14") + @Iteration("2^3==2^3", "answer=2^3", "input=2^3") + @Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14") + @Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)") fun testMatches_sameSingleOperations_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -100,12 +95,10 @@ class NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1!=0", "answer=1", "input=0"), - Iteration("0!=1", "answer=0", "input=1"), - Iteration("3.14!=1", "answer=3.14", "input=1"), - Iteration("1!=3.14", "answer=1", "input=3.14") - ) + @Iteration("1!=0", "answer=1", "input=0") + @Iteration("0!=1", "answer=0", "input=1") + @Iteration("3.14!=1", "answer=3.14", "input=1") + @Iteration("1!=3.14", "answer=1", "input=3.14") fun testMatches_differentSingleTerms_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -117,12 +110,10 @@ class NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("3.14+1!=1+3.14", "answer=3.14+1", "input=1+3.14"), - Iteration("3+2+1!=1+2+3", "answer=3+2+1", "input=1+2+3"), - Iteration("-3.14+1!=1-3.14", "answer=-3.14+1", "input=1-3.14"), - Iteration("3.14*2!=2*3.14", "answer=3.14*2", "input=2*3.14") - ) + @Iteration("3.14+1!=1+3.14", "answer=3.14+1", "input=1+3.14") + @Iteration("3+2+1!=1+2+3", "answer=3+2+1", "input=1+2+3") + @Iteration("-3.14+1!=1-3.14", "answer=-3.14+1", "input=1-3.14") + @Iteration("3.14*2!=2*3.14", "answer=3.14*2", "input=2*3.14") fun testMatches_operationsDiffer_byCommutativity_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -134,10 +125,8 @@ class NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1+(2+3)!=(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3"), - Iteration("2*(3*4)!=(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4") - ) + @Iteration("1+(2+3)!=(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3") + @Iteration("2*(3*4)!=(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4") fun testMatches_operationsDiffer_byAssociativity_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -149,17 +138,15 @@ class NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14"), - Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3"), - Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14"), - Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4"), - Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14"), - Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14"), - Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z"), - Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14"), - Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") - ) + @Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14") + @Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3") + @Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14") + @Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4") + @Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14") + @Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14") + @Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z") + @Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14") + @Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") fun testMatches_operationsDiffer_byNonCommutativeOrAssociativeReordering_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -172,17 +159,15 @@ class NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("1-2!=-(2-1)", "answer=1-2", "input=-(2-1)"), - Iteration("1+2!=1+1+1", "answer=1+2", "input=1+1+1"), - Iteration("1+2!=1-(-2)", "answer=1+2", "input=1-(-2)"), - Iteration("4-6!=1-2-1", "answer=4-6", "input=1-2-1"), - Iteration("2*3*2*2!=2*3*4", "answer=2*3*2*2", "input=2*3*4"), - Iteration("-6-2!=2*-(3+1)", "answer=-6-2", "input=2*-(3+1)"), - Iteration("2/3/2/2!=2/3/4", "answer=2/3/2/2", "input=2/3/4"), - Iteration("2^(2+1)!=2^3", "answer=2^(2+1)", "input=2^3"), - Iteration("2^(-1)!=1/2", "answer=2^(-1)", "input=1/2") - ) + @Iteration("1-2!=-(2-1)", "answer=1-2", "input=-(2-1)") + @Iteration("1+2!=1+1+1", "answer=1+2", "input=1+1+1") + @Iteration("1+2!=1-(-2)", "answer=1+2", "input=1-(-2)") + @Iteration("4-6!=1-2-1", "answer=4-6", "input=1-2-1") + @Iteration("2*3*2*2!=2*3*4", "answer=2*3*2*2", "input=2*3*4") + @Iteration("-6-2!=2*-(3+1)", "answer=-6-2", "input=2*-(3+1)") + @Iteration("2/3/2/2!=2/3/4", "answer=2/3/2/2", "input=2/3/4") + @Iteration("2^(2+1)!=2^3", "answer=2^(2+1)", "input=2^3") + @Iteration("2^(-1)!=1/2", "answer=2^(-1)", "input=1/2") fun testMatches_operationsDiffer_byDistributionAndCombining_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -194,28 +179,26 @@ class NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration( - "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", - "answer=2 * (50 + 150 + 100 + 25) ", - "input=2 × (50 + 150 + 100 + 25)" - ), - Iteration("5+2==5+2", "answer=5+2", "input=5+2"), - Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)"), - Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)"), - Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5"), - Iteration( - "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration( + "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", + "answer=2 * (50 + 150 + 100 + 25) ", + "input=2 × (50 + 150 + 100 + 25)" + ) + @Iteration("5+2==5+2", "answer=5+2", "input=5+2") + @Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)") + @Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)") + @Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5") + @Iteration( + "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" ) + @Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3") fun testMatches_assortedExpressions_withMatchingCharacteristics_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -228,110 +211,108 @@ class NumericExpressionInputMatchesExactlyWithRuleClassifierProviderTest { } @Test - @RunParameterized( - Iteration( - "2 × (50 + 150 + 100 + 25) !=(50 + 150 + 100 + 25) × 2", - "answer=2 × (50 + 150 + 100 + 25) ", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration("− (− 4) + 6!=6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)"), - Iteration("10!=6 − (− 4)", "answer=10", "input=6 − (− 4)"), - Iteration("6 + 4!=6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)"), - Iteration("6 + 2^2!=6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)"), - Iteration("3 * 2 − (− 4)!=6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)"), - Iteration("100/10!=6 − (− 4)", "answer=100/10", "input=6 − (− 4)"), - Iteration("2+5!=5+2", "answer=2+5", "input=5+2"), - Iteration("3/(10 * 10^4)!=3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5"), - Iteration( - "200 + 30 + 4 + 0.5 + 0.06 + 1000!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "0.06 + 0.5 + 4 + 30 + 200 + 1000!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1234.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "123456/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456/100", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "61728/50!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=61728/50", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1234 + 56/10!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234 + 56/10", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1230 + 4.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1230 + 4.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "2 * 2 * 3 * 3 * 1!=2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" - ), - Iteration("2 * 2 * 9!=2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3"), - Iteration("4 * 3^2!=2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3"), - Iteration("8/2 * 3 * 3!=2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration("36!=2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3"), - Iteration("sqrt(4-2)!=sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)"), - Iteration("2*(6+3+4) + 4!=2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)"), - Iteration("2*(2+6+3) + 8!=2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)"), - Iteration("(2+6+3+4)*2!=2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)"), - Iteration("(2+6+3+4) × 2!=2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)"), - Iteration("15 - 12 + 3!=15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3"), - Iteration( - "3 - (6 * 2) + 15!=15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" - ), - Iteration( - "15 - (2 × 6) + 3!=15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2 *(50 + 150) + 2*(100 + 25)!=(50 + 150 + 100 + 25) × 2", - "answer=2 *(50 + 150) + 2*(100 + 25)", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration( - "2* ( 25+50+100+150)!=(50 + 150 + 100 + 25) × 2", - "answer=2* ( 25+50+100+150)", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration("10^−5 * 3!=3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5"), - Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5"), - Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5"), - Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5"), - Iteration("30 * 10^−6!=3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5"), - Iteration("0.00003!=3 * 10^-5", "answer=0.00003", "input=3 * 10^-5"), - Iteration("3/10^5!=3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5"), - Iteration( - "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("3 *2 – (− 4)!=6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)"), - Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)"), - Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)"), - Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)"), - Iteration("7!=5+2", "answer=7", "input=5+2"), - Iteration("3+4!=5+2", "answer=3+4", "input=5+2"), - Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3"), - Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration( + "2 × (50 + 150 + 100 + 25) !=(50 + 150 + 100 + 25) × 2", + "answer=2 × (50 + 150 + 100 + 25) ", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration("− (− 4) + 6!=6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)") + @Iteration("10!=6 − (− 4)", "answer=10", "input=6 − (− 4)") + @Iteration("6 + 4!=6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)") + @Iteration("6 + 2^2!=6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)") + @Iteration("3 * 2 − (− 4)!=6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)") + @Iteration("100/10!=6 − (− 4)", "answer=100/10", "input=6 − (− 4)") + @Iteration("2+5!=5+2", "answer=2+5", "input=5+2") + @Iteration("3/(10 * 10^4)!=3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5") + @Iteration( + "200 + 30 + 4 + 0.5 + 0.06 + 1000!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "0.06 + 0.5 + 4 + 30 + 200 + 1000!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1234.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "123456/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456/100", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "61728/50!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=61728/50", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1234 + 56/10!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234 + 56/10", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1230 + 4.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1230 + 4.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "2 * 2 * 3 * 3 * 1!=2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" + ) + @Iteration("2 * 2 * 9!=2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3") + @Iteration("4 * 3^2!=2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3") + @Iteration("8/2 * 3 * 3!=2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("36!=2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3") + @Iteration("sqrt(4-2)!=sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)") + @Iteration("2*(6+3+4) + 4!=2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)") + @Iteration("2*(2+6+3) + 8!=2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)") + @Iteration("(2+6+3+4)*2!=2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)") + @Iteration("(2+6+3+4) × 2!=2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)") + @Iteration("15 - 12 + 3!=15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3") + @Iteration( + "3 - (6 * 2) + 15!=15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "15 - (2 × 6) + 3!=15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "2 *(50 + 150) + 2*(100 + 25)!=(50 + 150 + 100 + 25) × 2", + "answer=2 *(50 + 150) + 2*(100 + 25)", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration( + "2* ( 25+50+100+150)!=(50 + 150 + 100 + 25) × 2", + "answer=2* ( 25+50+100+150)", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration("10^−5 * 3!=3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5") + @Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5") + @Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5") + @Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5") + @Iteration("30 * 10^−6!=3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5") + @Iteration("0.00003!=3 * 10^-5", "answer=0.00003", "input=3 * 10^-5") + @Iteration("3/10^5!=3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5") + @Iteration( + "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" ) + @Iteration("3 *2 – (− 4)!=6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)") + @Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)") + @Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)") + @Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)") + @Iteration("7!=5+2", "answer=7", "input=5+2") + @Iteration("3+4!=5+2", "answer=3+4", "input=5+2") + @Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3") + @Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3") fun testMatches_assortedExpressions_withoutMatchingCharacteristics_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) diff --git a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt index 9e095d504dd..d4ad34e873a 100644 --- a/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/classify/rules/numericexpressioninput/NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProviderTest.kt @@ -17,7 +17,6 @@ import org.oppia.android.domain.classify.RuleClassifier import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -60,11 +59,9 @@ class NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvide } @Test - @RunParameterized( - Iteration("0==0", "answer=0", "input=0"), - Iteration("1==1", "answer=1", "input=1"), - Iteration("2==2", "answer=2", "input=2") - ) + @Iteration("0==0", "answer=0", "input=0") + @Iteration("1==1", "answer=1", "input=1") + @Iteration("2==2", "answer=2", "input=2") fun testMatches_sameSingleTerms_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -76,19 +73,17 @@ class NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvide } @Test - @RunParameterized( - Iteration("-2==-2", "answer=-2", "input=-2"), - Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14"), - Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14"), - Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3"), - Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14"), - Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14"), - Iteration("2/3==2/3", "answer=2/3", "input=2/3"), - Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14"), - Iteration("2^3==2^3", "answer=2^3", "input=2^3"), - Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14"), - Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)") - ) + @Iteration("-2==-2", "answer=-2", "input=-2") + @Iteration("1+3.14==1+3.14", "answer=1+3.14", "input=1+3.14") + @Iteration(" 1 + 3.14 ==1+3.14", "answer= 1 + 3.14 ", "input=1+3.14") + @Iteration("1+2+3==1+2+3", "answer=1+2+3", "input=1+2+3") + @Iteration("1-3.14==1-3.14", "answer=1-3.14", "input=1-3.14") + @Iteration("2*3.14==2*3.14", "answer=2*3.14", "input=2*3.14") + @Iteration("2/3==2/3", "answer=2/3", "input=2/3") + @Iteration("2/3.14==2/3.14", "answer=2/3.14", "input=2/3.14") + @Iteration("2^3==2^3", "answer=2^3", "input=2^3") + @Iteration("2^3.14==2^3.14", "answer=2^3.14", "input=2^3.14") + @Iteration("sqrt(2)==sqrt(2)", "answer=sqrt(2)", "input=sqrt(2)") fun testMatches_sameSingleOperations_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -100,12 +95,10 @@ class NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvide } @Test - @RunParameterized( - Iteration("1!=0", "answer=1", "input=0"), - Iteration("0!=1", "answer=0", "input=1"), - Iteration("3.14!=1", "answer=3.14", "input=1"), - Iteration("1!=3.14", "answer=1", "input=3.14") - ) + @Iteration("1!=0", "answer=1", "input=0") + @Iteration("0!=1", "answer=0", "input=1") + @Iteration("3.14!=1", "answer=3.14", "input=1") + @Iteration("1!=3.14", "answer=1", "input=3.14") fun testMatches_differentSingleTerms_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -118,12 +111,10 @@ class NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvide } @Test - @RunParameterized( - Iteration("3.14+1==1+3.14", "answer=3.14+1", "input=1+3.14"), - Iteration("3+2+1==1+2+3", "answer=3+2+1", "input=1+2+3"), - Iteration("-3.14+1==1-3.14", "answer=-3.14+1", "input=1-3.14"), - Iteration("3.14*2==2*3.14", "answer=3.14*2", "input=2*3.14") - ) + @Iteration("3.14+1==1+3.14", "answer=3.14+1", "input=1+3.14") + @Iteration("3+2+1==1+2+3", "answer=3+2+1", "input=1+2+3") + @Iteration("-3.14+1==1-3.14", "answer=-3.14+1", "input=1-3.14") + @Iteration("3.14*2==2*3.14", "answer=3.14*2", "input=2*3.14") fun testMatches_operationsDiffer_byCommutativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -135,10 +126,8 @@ class NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvide } @Test - @RunParameterized( - Iteration("1+(2+3)==(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3"), - Iteration("2*(3*4)==(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4") - ) + @Iteration("1+(2+3)==(1+2)+3", "answer=1+(2+3)", "input=(1+2)+3") + @Iteration("2*(3*4)==(2*3)*4", "answer=2*(3*4)", "input=(2*3)*4") fun testMatches_operationsDiffer_byAssociativity_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -150,17 +139,15 @@ class NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvide } @Test - @RunParameterized( - Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14"), - Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3"), - Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14"), - Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4"), - Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14"), - Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14"), - Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z"), - Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14"), - Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") - ) + @Iteration("3.14-1!=1-3.14", "answer=3.14-1", "input=1-3.14") + @Iteration("1-(2-3)!=(1-2)-3", "answer=1-(2-3)", "input=(1-2)-3") + @Iteration("3.14/2!=2/3.14", "answer=3.14/2", "input=2/3.14") + @Iteration("2/(3/4)!=(2/3)/4", "answer=2/(3/4)", "input=(2/3)/4") + @Iteration("3.14^2!=2^3.14", "answer=3.14^2", "input=2^3.14") + @Iteration("3.14-x!=x-3.14", "answer=3.14-x", "input=x-3.14") + @Iteration("x-(y-z)!=(x-y)-z", "answer=x-(y-z)", "input=(x-y)-z") + @Iteration("3.14/x!=x/3.14", "answer=3.14/x", "input=x/3.14") + @Iteration("x/(y/z)!=(x/y)/z", "answer=x/(y/z)", "input=(x/y)/z") fun testMatches_operationsDiffer_byNonCommutativeOrAssociativeReordering_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -173,9 +160,7 @@ class NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvide } @Test - @RunParameterized( - Iteration("1+2==1-(-2)", "answer=1+2", "input=1-(-2)") - ) + @Iteration("1+2==1-(-2)", "answer=1+2", "input=1-(-2)") fun testMatches_operationsDiffer_byDistributingNegation_returnsTrue() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -187,16 +172,14 @@ class NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvide } @Test - @RunParameterized( - Iteration("1-2==-(2-1)", "answer=1-2", "input=-(2-1)"), - Iteration("1+2!=1+1+1", "answer=1+2", "input=1+1+1"), - Iteration("4-6!=1-2-1", "answer=4-6", "input=1-2-1"), - Iteration("2*3*2*2!=2*3*4", "answer=2*3*2*2", "input=2*3*4"), - Iteration("-6-2!=2*-(3+1)", "answer=-6-2", "input=2*-(3+1)"), - Iteration("2/3/2/2!=2/3/4", "answer=2/3/2/2", "input=2/3/4"), - Iteration("2^(2+1)!=2^3", "answer=2^(2+1)", "input=2^3"), - Iteration("2^(-1)!=1/2", "answer=2^(-1)", "input=1/2") - ) + @Iteration("1-2==-(2-1)", "answer=1-2", "input=-(2-1)") + @Iteration("1+2!=1+1+1", "answer=1+2", "input=1+1+1") + @Iteration("4-6!=1-2-1", "answer=4-6", "input=1-2-1") + @Iteration("2*3*2*2!=2*3*4", "answer=2*3*2*2", "input=2*3*4") + @Iteration("-6-2!=2*-(3+1)", "answer=-6-2", "input=2*-(3+1)") + @Iteration("2/3/2/2!=2/3/4", "answer=2/3/2/2", "input=2/3/4") + @Iteration("2^(2+1)!=2^3", "answer=2^(2+1)", "input=2^3") + @Iteration("2^(-1)!=1/2", "answer=2^(-1)", "input=1/2") fun testMatches_operationsDiffer_byDistributionAndCombining_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) @@ -208,59 +191,57 @@ class NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvide } @Test - @RunParameterized( - Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)"), - Iteration( - "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2 × (50 + 150 + 100 + 25) ==(50 + 150 + 100 + 25) × 2", - "answer=2 × (50 + 150 + 100 + 25) ", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration( - "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", - "answer=2 * (50 + 150 + 100 + 25) ", - "input=2 × (50 + 150 + 100 + 25)" - ), - Iteration("2+5==5+2", "answer=2+5", "input=5+2"), - Iteration("5+2==5+2", "answer=5+2", "input=5+2"), - Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)"), - Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)"), - Iteration("− (− 4) + 6==6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)"), - Iteration("6 + 4!=6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)"), - Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5"), - Iteration("10^−5 * 3==3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5"), - Iteration( - "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "200 + 30 + 4 + 0.5 + 0.06 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "0.06 + 0.5 + 4 + 30 + 200 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration("(2+6+3+4)*2==2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)"), - Iteration("(2+6+3+4) × 2==2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)"), - Iteration( - "3 - (6 * 2) + 15==15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" - ), - Iteration( - "15 - (2 × 6) + 3==15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" - ), - Iteration( - "2* ( 25+50+100+150)==(50 + 150 + 100 + 25) × 2", - "answer=2* ( 25+50+100+150)", - "input=(50 + 150 + 100 + 25) × 2" - ) + @Iteration("2*(2+6+3+4)==2*(2+6+3+4)", "answer=2*(2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration("2 × (2+6+3+4)==2*(2+6+3+4)", "answer=2 × (2+6+3+4)", "input=2*(2+6+3+4)") + @Iteration( + "15 - (6 × 2) + 3==15 - (6 × 2) + 3", "answer=15 - (6 × 2) + 3", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "2 × (50 + 150 + 100 + 25) ==(50 + 150 + 100 + 25) × 2", + "answer=2 × (50 + 150 + 100 + 25) ", + "input=(50 + 150 + 100 + 25) × 2" + ) + @Iteration( + "2 * (50 + 150 + 100 + 25) ==2 × (50 + 150 + 100 + 25)", + "answer=2 * (50 + 150 + 100 + 25) ", + "input=2 × (50 + 150 + 100 + 25)" + ) + @Iteration("2+5==5+2", "answer=2+5", "input=5+2") + @Iteration("5+2==5+2", "answer=5+2", "input=5+2") + @Iteration("6 − (− 4)==6 − (− 4)", "answer=6 − (− 4)", "input=6 − (− 4)") + @Iteration("6-(-4)==6 − (− 4)", "answer=6-(-4)", "input=6 − (− 4)") + @Iteration("− (− 4) + 6==6 − (− 4)", "answer=− (− 4) + 6", "input=6 − (− 4)") + @Iteration("6 + 4!=6 − (− 4)", "answer=6 + 4", "input=6 − (− 4)") + @Iteration("3 * 10^-5==3 * 10^-5", "answer=3 * 10^-5", "input=3 * 10^-5") + @Iteration("10^−5 * 3==3 * 10^-5", "answer=10^−5 * 3", "input=3 * 10^-5") + @Iteration( + "1000 + 200 + 30 + 4 + 0.5 + 0.06==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "200 + 30 + 4 + 0.5 + 0.06 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=200 + 30 + 4 + 0.5 + 0.06 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "0.06 + 0.5 + 4 + 30 + 200 + 1000==1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=0.06 + 0.5 + 4 + 30 + 200 + 1000", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration("2 * 2 * 3 * 3==2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("(2+6+3+4)*2==2*(2+6+3+4)", "answer=(2+6+3+4)*2", "input=2*(2+6+3+4)") + @Iteration("(2+6+3+4) × 2==2*(2+6+3+4)", "answer=(2+6+3+4) × 2", "input=2*(2+6+3+4)") + @Iteration( + "3 - (6 * 2) + 15==15 - (6 × 2) + 3", "answer=3 - (6 * 2) + 15", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "15 - (2 × 6) + 3==15 - (6 × 2) + 3", "answer=15 - (2 × 6) + 3", "input=15 - (6 × 2) + 3" + ) + @Iteration( + "2* ( 25+50+100+150)==(50 + 150 + 100 + 25) × 2", + "answer=2* ( 25+50+100+150)", + "input=(50 + 150 + 100 + 25) × 2" ) fun testMatches_assortedExpressions_withMatchingCharacteristics_returnsTrue() { val answerExpression = createMathExpression(answer) @@ -274,78 +255,76 @@ class NumericExpressionInputMatchesUpToTrivialManipulationsRuleClassifierProvide } @Test - @RunParameterized( - Iteration("10!=6 − (− 4)", "answer=10", "input=6 − (− 4)"), - Iteration("6 + 2^2!=6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)"), - Iteration("3 * 2 − (− 4)!=6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)"), - Iteration("100/10!=6 − (− 4)", "answer=100/10", "input=6 − (− 4)"), - Iteration("3/(10 * 10^4)!=3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5"), - Iteration( - "1234.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "123456/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456/100", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "61728/50!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=61728/50", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1234 + 56/10!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1234 + 56/10", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1230 + 4.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1230 + 4.56", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "2 * 2 * 3 * 3 * 1!=2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" - ), - Iteration("2 * 2 * 9!=2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3"), - Iteration("4 * 3^2!=2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3"), - Iteration("8/2 * 3 * 3!=2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration("36!=2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3"), - Iteration("sqrt(4-2)!=sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)"), - Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5"), - Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5"), - Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5"), - Iteration("30 * 10^−6!=3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5"), - Iteration("0.00003!=3 * 10^-5", "answer=0.00003", "input=3 * 10^-5"), - Iteration("3/10^5!=3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5"), - Iteration( - "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=123456", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration( - "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", - "answer=1000 + 200 + 30", - "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" - ), - Iteration("3 *2 – (− 4)!=6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)"), - Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)"), - Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)"), - Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)"), - Iteration("7!=5+2", "answer=7", "input=5+2"), - Iteration("3+4!=5+2", "answer=3+4", "input=5+2"), - Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3"), - Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3"), - Iteration( - "2 *(50 + 150) + 2*(100 + 25)!=(50 + 150 + 100 + 25) × 2", - "answer=2 *(50 + 150) + 2*(100 + 25)", - "input=(50 + 150 + 100 + 25) × 2" - ), - Iteration("15 - 12 + 3!=15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3"), - Iteration("2*(6+3+4) + 4!=2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)"), - Iteration("2*(2+6+3) + 8!=2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)") + @Iteration("10!=6 − (− 4)", "answer=10", "input=6 − (− 4)") + @Iteration("6 + 2^2!=6 − (− 4)", "answer=6 + 2^2", "input=6 − (− 4)") + @Iteration("3 * 2 − (− 4)!=6 − (− 4)", "answer=3 * 2 − (− 4)", "input=6 − (− 4)") + @Iteration("100/10!=6 − (− 4)", "answer=100/10", "input=6 − (− 4)") + @Iteration("3/(10 * 10^4)!=3 * 10^-5", "answer=3/(10 * 10^4)", "input=3 * 10^-5") + @Iteration( + "1234.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "123456/100!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456/100", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "61728/50!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=61728/50", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1234 + 56/10!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1234 + 56/10", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1230 + 4.56!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1230 + 4.56", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "2 * 2 * 3 * 3 * 1!=2 * 2 * 3 * 3", "answer=2 * 2 * 3 * 3 * 1", "input=2 * 2 * 3 * 3" + ) + @Iteration("2 * 2 * 9!=2 * 2 * 3 * 3", "answer=2 * 2 * 9", "input=2 * 2 * 3 * 3") + @Iteration("4 * 3^2!=2 * 2 * 3 * 3", "answer=4 * 3^2", "input=2 * 2 * 3 * 3") + @Iteration("8/2 * 3 * 3!=2 * 2 * 3 * 3", "answer=8/2 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration("36!=2 * 2 * 3 * 3", "answer=36", "input=2 * 2 * 3 * 3") + @Iteration("sqrt(4-2)!=sqrt(2)", "answer=sqrt(4-2)", "input=sqrt(2)") + @Iteration("3 * 10^5!=3 * 10^-5", "answer=3 * 10^5", "input=3 * 10^-5") + @Iteration("2 * 10^−5!=3 * 10^-5", "answer=2 * 10^−5", "input=3 * 10^-5") + @Iteration("5 * 10^−3!=3 * 10^-5", "answer=5 * 10^−3", "input=3 * 10^-5") + @Iteration("30 * 10^−6!=3 * 10^-5", "answer=30 * 10^−6", "input=3 * 10^-5") + @Iteration("0.00003!=3 * 10^-5", "answer=0.00003", "input=3 * 10^-5") + @Iteration("3/10^5!=3 * 10^-5", "answer=3/10^5", "input=3 * 10^-5") + @Iteration( + "123456!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=123456", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration( + "1000 + 200 + 30!=1000 + 200 + 30 + 4 + 0.5 + 0.06", + "answer=1000 + 200 + 30", + "input=1000 + 200 + 30 + 4 + 0.5 + 0.06" + ) + @Iteration("3 *2 – (− 4)!=6 − (− 4)", "answer=3 *2 – (− 4)", "input=6 − (− 4)") + @Iteration("6 − 4!=6 − (− 4)", "answer=6 − 4", "input=6 − (− 4)") + @Iteration("6 + (− 4)!=6 − (− 4)", "answer=6 + (− 4)", "input=6 − (− 4)") + @Iteration("100!=6 − (− 4)", "answer=100", "input=6 − (− 4)") + @Iteration("7!=5+2", "answer=7", "input=5+2") + @Iteration("3+4!=5+2", "answer=3+4", "input=5+2") + @Iteration("2 * 2 * 3!=2 * 2 * 3 * 3", "answer=2 * 2 * 3", "input=2 * 2 * 3 * 3") + @Iteration("2 * 3 * 3 * 3!=2 * 2 * 3 * 3", "answer=2 * 3 * 3 * 3", "input=2 * 2 * 3 * 3") + @Iteration( + "2 *(50 + 150) + 2*(100 + 25)!=(50 + 150 + 100 + 25) × 2", + "answer=2 *(50 + 150) + 2*(100 + 25)", + "input=(50 + 150 + 100 + 25) × 2" ) + @Iteration("15 - 12 + 3!=15 - (6 × 2) + 3", "answer=15 - 12 + 3", "input=15 - (6 × 2) + 3") + @Iteration("2*(6+3+4) + 4!=2*(2+6+3+4)", "answer=2*(6+3+4) + 4", "input=2*(2+6+3+4)") + @Iteration("2*(2+6+3) + 8!=2*(2+6+3+4)", "answer=2*(2+6+3) + 8", "input=2*(2+6+3+4)") fun testMatches_assortedExpressions_withoutMatchingCharacteristics_returnsFalse() { val answerExpression = createMathExpression(answer) val inputExpression = createMathExpression(input) diff --git a/domain/src/test/java/org/oppia/android/domain/onboarding/AppStartupStateControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/onboarding/AppStartupStateControllerTest.kt index 813e82f1827..92c96177489 100644 --- a/domain/src/test/java/org/oppia/android/domain/onboarding/AppStartupStateControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/onboarding/AppStartupStateControllerTest.kt @@ -46,7 +46,6 @@ import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -706,12 +705,10 @@ class AppStartupStateControllerTest { } @Test - @RunParameterized( - Iteration("testing_to_beta", "initialFlavorName=TESTING"), - Iteration("dev_to_beta", "initialFlavorName=DEVELOPER"), - Iteration("alpha_to_beta", "initialFlavorName=ALPHA"), - Iteration("ga_to_beta", "initialFlavorName=GENERAL_AVAILABILITY") - ) + @Iteration("testing_to_beta", "initialFlavorName=TESTING") + @Iteration("dev_to_beta", "initialFlavorName=DEVELOPER") + @Iteration("alpha_to_beta", "initialFlavorName=ALPHA") + @Iteration("ga_to_beta", "initialFlavorName=GENERAL_AVAILABILITY") fun testController_dismissBetaNoticePermanently_scenariosWhenBetaNoticeDoesShow_showNoNotice() { executeInPreviousAppInstance { testComponent -> TestModule.buildFlavor = BuildFlavor.valueOf(initialFlavorName) @@ -733,10 +730,8 @@ class AppStartupStateControllerTest { } @Test - @RunParameterized( - Iteration("testing_to_ga", "initialFlavorName=TESTING"), - Iteration("dev_to_ga", "initialFlavorName=DEVELOPER") - ) + @Iteration("testing_to_ga", "initialFlavorName=TESTING") + @Iteration("dev_to_ga", "initialFlavorName=DEVELOPER") fun testController_dismissGaNoticePermanently_scenariosWhenGaNoticeDoesNotShow_showNoNotice() { executeInPreviousAppInstance { testComponent -> TestModule.buildFlavor = BuildFlavor.valueOf(initialFlavorName) @@ -758,10 +753,8 @@ class AppStartupStateControllerTest { } @Test - @RunParameterized( - Iteration("alpha_to_ga", "initialFlavorName=ALPHA"), - Iteration("beta_to_ga", "initialFlavorName=BETA") - ) + @Iteration("alpha_to_ga", "initialFlavorName=ALPHA") + @Iteration("beta_to_ga", "initialFlavorName=BETA") fun testController_dismissGaNoticePermanently_scenariosWhenGaNoticeDoesShow_showNoNotice() { executeInPreviousAppInstance { testComponent -> TestModule.buildFlavor = BuildFlavor.valueOf(initialFlavorName) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt index b477b24bd75..2562ecbfca5 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/LearnerAnalyticsLoggerTest.kt @@ -49,7 +49,6 @@ import org.oppia.android.testing.firebase.TestAuthenticationModule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.logging.EventLogSubject.Companion.assertThat @@ -1130,11 +1129,9 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install"), - Iteration("missing_install_and_learner_ids", "lid=null", "iid=null", "elid=", "eid=") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") + @Iteration("missing_install_and_learner_ids", "lid=null", "iid=null", "elid=", "eid=") fun testExpLogger_logResumeExploration_missingOneOrMoreIds_logsEventWithMissingIds() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1154,11 +1151,9 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install"), - Iteration("missing_install_and_learner_ids", "lid=null", "iid=null", "elid=", "eid=") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") + @Iteration("missing_install_and_learner_ids", "lid=null", "iid=null", "elid=", "eid=") fun testExpLogger_logStartExplorationOver_missingOneOrMoreIds_logsEventWithMissingIds() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1178,10 +1173,8 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") fun testExpLogger_logExitExploration_missingOneId_logsEventWithMissingId() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1225,10 +1218,8 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") fun testExpLogger_logFinishExploration_missingOneId_logsEventWithMissingId() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1270,10 +1261,8 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") fun testStateAnalyticsLogger_logStartCard_missingOneId_logsEventWithMissingId() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1317,10 +1306,8 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") fun testStateAnalyticsLogger_logEndCard_missingOneId_logsEventWithMissingId() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1364,10 +1351,8 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") fun testStateAnalyticsLogger_logHintUnlocked_missingOneId_logsEventWithMissingId() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1411,10 +1396,8 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") fun testStateAnalyticsLogger_logViewHint_missingOneId_logsEventWithMissingId() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1458,10 +1441,8 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") fun testStateAnalyticsLogger_logSolutionUnlocked_missingOneId_logsEventWithMissingId() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1503,10 +1484,8 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") fun testStateAnalyticsLogger_logViewSolution_missingOneId_logsEventWithMissingId() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1548,10 +1527,8 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") fun testStateAnalyticsLogger_logSubmitAnswer_missingOneId_logsEventWithMissingId() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1603,10 +1580,8 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") fun testStateAnalyticsLogger_logPlayVoiceOver_missingOneId_logsEventWithMissingId() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = @@ -1650,10 +1625,8 @@ class LearnerAnalyticsLoggerTest { } @Test - @RunParameterized( - Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid="), - Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") - ) + @Iteration("no_install_id", "lid=learn", "iid=null", "elid=learn", "eid=") + @Iteration("no_learner_id", "lid=null", "iid=install", "elid=", "eid=install") fun testStateAnalyticsLogger_logPauseVoiceOver_missingOneId_logsEventWithMissingId() { val exploration5 = loadExploration(TEST_EXPLORATION_ID_5) val expLogger = diff --git a/gradle.properties b/gradle.properties index 6efd2e7dbe5..171b9cb7ba1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,7 +18,7 @@ org.gradle.caching=-true # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true +android.enableJetifier=false # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official # Needed to enable Android data binding. diff --git a/scripts/assets/file_content_validation_checks.textproto b/scripts/assets/file_content_validation_checks.textproto index 79485419912..eca06c82432 100644 --- a/scripts/assets/file_content_validation_checks.textproto +++ b/scripts/assets/file_content_validation_checks.textproto @@ -31,10 +31,7 @@ file_content_checks { file_content_checks { file_path_regex: ".+?\\.kt" prohibited_content_regex: "SettableFuture" - failure_message: "SettableFuture should only be used in pre-approved locations since it's easy to potentially mess up & lead to a hanging ListenableFuture." - exempted_file_name: "domain/src/main/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorker.kt" - exempted_file_name: "domain/src/main/java/org/oppia/android/domain/platformparameter/syncup/PlatformParameterSyncUpWorker.kt" - exempted_file_name: "domain/src/main/java/org/oppia/android/domain/oppialogger/logscheduler/MetricLogSchedulingWorker.kt" + failure_message: "SettableFuture should only be used in pre-approved locations since it's easy to potentially mess up & lead to a hanging ListenableFuture. If using a Deferred, convert it to a ListenableFuture using asListenableFuture()." exempted_file_name: "scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt" } file_content_checks { diff --git a/scripts/assets/maven_dependencies.textproto b/scripts/assets/maven_dependencies.textproto index 6498f36a747..eb4db32a1fb 100644 --- a/scripts/assets/maven_dependencies.textproto +++ b/scripts/assets/maven_dependencies.textproto @@ -968,8 +968,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "com.google.auto.service:auto-service-annotations:1.0-rc7" - artifact_version: "1.0-rc7" + artifact_name: "com.google.auto.service:auto-service-annotations:1.0" + artifact_version: "1.0" license { license_name: "The Apache Software License, Version 2.0" scrapable_link { @@ -1326,8 +1326,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "com.squareup.moshi:moshi:1.11.0" - artifact_version: "1.11.0" + artifact_name: "com.squareup.moshi:moshi:1.13.0" + artifact_version: "1.13.0" license { license_name: "The Apache Software License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1337,8 +1337,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "com.squareup.moshi:moshi-kotlin:1.11.0" - artifact_version: "1.11.0" + artifact_name: "com.squareup.moshi:moshi-kotlin:1.13.0" + artifact_version: "1.13.0" license { license_name: "The Apache Software License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1348,8 +1348,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "com.squareup.moshi:moshi-kotlin-codegen:1.11.0" - artifact_version: "1.11.0" + artifact_name: "com.squareup.moshi:moshi-kotlin-codegen:1.13.0" + artifact_version: "1.13.0" license { license_name: "The Apache Software License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1381,8 +1381,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "com.squareup.okio:okio:2.6.0" - artifact_version: "2.6.0" + artifact_name: "com.squareup.okio:okio:2.10.0" + artifact_version: "2.10.0" license { license_name: "The Apache Software License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1413,8 +1413,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "com.squareup:kotlinpoet:1.6.0" - artifact_version: "1.6.0" + artifact_name: "com.squareup:kotlinpoet:1.10.2" + artifact_version: "1.10.2" license { license_name: "The Apache Software License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1552,17 +1552,6 @@ maven_dependency { } } } -maven_dependency { - artifact_name: "net.ltgt.gradle.incap:incap:0.3" - artifact_version: "0.3" - license { - license_name: "The Apache License, Version 2.0" - original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" - scrapable_link { - url: "https://www.apache.org/licenses/LICENSE-2.0.txt" - } - } -} maven_dependency { artifact_name: "nl.dionsegijn:konfetti:1.2.5" artifact_version: "1.2.5" @@ -1615,8 +1604,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "org.jetbrains.kotlin:kotlin-reflect:1.5.0" - artifact_version: "1.5.0" + artifact_name: "org.jetbrains.kotlin:kotlin-reflect:1.6.0" + artifact_version: "1.6.0" license { license_name: "The Apache License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1626,8 +1615,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "org.jetbrains.kotlin:kotlin-stdlib:1.5.32" - artifact_version: "1.5.32" + artifact_name: "org.jetbrains.kotlin:kotlin-stdlib:1.6.21" + artifact_version: "1.6.21" license { license_name: "The Apache License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1637,8 +1626,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "org.jetbrains.kotlin:kotlin-stdlib-common:1.5.32" - artifact_version: "1.5.32" + artifact_name: "org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21" + artifact_version: "1.6.21" license { license_name: "The Apache License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1648,8 +1637,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.32" - artifact_version: "1.5.32" + artifact_name: "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21" + artifact_version: "1.6.21" license { license_name: "The Apache License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1659,8 +1648,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32" - artifact_version: "1.5.32" + artifact_name: "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21" + artifact_version: "1.6.21" license { license_name: "The Apache License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1670,8 +1659,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1" - artifact_version: "1.4.1" + artifact_name: "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" + artifact_version: "1.6.4" license { license_name: "The Apache Software License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1681,8 +1670,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3" - artifact_version: "1.4.3" + artifact_name: "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4" + artifact_version: "1.6.4" license { license_name: "The Apache Software License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1692,8 +1681,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.4.3" - artifact_version: "1.4.3" + artifact_name: "org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.6.4" + artifact_version: "1.6.4" license { license_name: "The Apache Software License, Version 2.0" original_link: "https://www.apache.org/licenses/LICENSE-2.0.txt" @@ -1714,8 +1703,8 @@ maven_dependency { } } maven_dependency { - artifact_name: "org.ow2.asm:asm:9.1" - artifact_version: "9.1" + artifact_name: "org.ow2.asm:asm:9.2" + artifact_version: "9.2" license { license_name: "BSD-3-Clause" original_link: "https://asm.ow2.io/license.html" diff --git a/scripts/src/java/org/oppia/android/scripts/build/FilterPerLanguageResources.kt b/scripts/src/java/org/oppia/android/scripts/build/FilterPerLanguageResources.kt index 96cdcef2282..e0bc2f6ac9e 100644 --- a/scripts/src/java/org/oppia/android/scripts/build/FilterPerLanguageResources.kt +++ b/scripts/src/java/org/oppia/android/scripts/build/FilterPerLanguageResources.kt @@ -8,7 +8,6 @@ import com.android.aapt.Resources.Type import org.oppia.android.app.model.LanguageSupportDefinition import org.oppia.android.app.model.SupportedLanguages import java.io.File -import java.util.Locale import java.util.zip.ZipEntry import java.util.zip.ZipFile import java.util.zip.ZipOutputStream @@ -65,22 +64,29 @@ private class FilterPerLanguageResources { } } - val allReferencedLanguageCodes = + val allReferencedLanguageLocales = pkg.typeList.flatMap { it.entryList } .flatMap { it.configValueList } .map { it.config } .map { it.locale } - .toSortedSet() - val supportedLanguageCodes = + .map { LanguageLocale.createFrom(it) } + .toSet() + val supportedLanguageLocales = supportedLanguages.languageDefinitionsList.mapNotNull { - it.toAndroidBcp47Locale() - }.toSortedSet() - val removedLanguageCodes = allReferencedLanguageCodes - supportedLanguageCodes - val updatedResourceTable = resourceTable.recompute(supportedLanguageCodes) + LanguageLocale.createFrom(it) + }.toSet() + val removedLanguageCodes = + (allReferencedLanguageLocales - supportedLanguageLocales).sortedBy { + it.androidBcp47QualifiedCode + } + val updatedResourceTable = resourceTable.recompute(supportedLanguageLocales) println( "${resourceTable.countResources() - updatedResourceTable.countResources()} resources are" + - " being removed that are tied to unsupported languages: $removedLanguageCodes (size" + - " reduction: ${resourceTable.serializedSize - updatedResourceTable.serializedSize} bytes)." + " being removed that are tied to unsupported languages: ${removedLanguageCodes.map { + it.androidBcp47QualifiedCode + } } (size reduction: ${ + resourceTable.serializedSize - updatedResourceTable.serializedSize + } bytes)." ) ZipOutputStream(outputModuleZip.outputStream()).use { outputStream -> @@ -95,20 +101,18 @@ private class FilterPerLanguageResources { } } - private fun ResourceTable.countResources(): Int = packageList.sumOf { it.countResources() } - - private fun ResourceTable.recompute(allowedLanguageCodes: Set): ResourceTable { - val updatedPackages = packageList.mapNotNull { it.recompute(allowedLanguageCodes) } + private fun ResourceTable.recompute(allowedLanguageLocales: Set): ResourceTable { + val updatedPackages = packageList.mapNotNull { it.recompute(allowedLanguageLocales) } return toBuilder().apply { clearPackage() addAllPackage(updatedPackages) }.build() } - private fun Package.countResources(): Int = typeList.sumOf { it.countResources() } + private fun ResourceTable.countResources(): Int = packageList.sumOf { it.countResources() } - private fun Package.recompute(allowedLanguageCodes: Set): Package? { - val updatedTypes = typeList.mapNotNull { it.recompute(allowedLanguageCodes) } + private fun Package.recompute(allowedLanguageLocales: Set): Package? { + val updatedTypes = typeList.mapNotNull { it.recompute(allowedLanguageLocales) } return if (updatedTypes.isNotEmpty()) { toBuilder().apply { clearType() @@ -117,10 +121,10 @@ private class FilterPerLanguageResources { } else null } - private fun Type.countResources(): Int = entryList.sumOf { it.configValueCount } + private fun Package.countResources(): Int = typeList.sumOf { it.countResources() } - private fun Type.recompute(allowedLanguageCodes: Set): Type? { - val updatedEntries = entryList.mapNotNull { it.recompute(allowedLanguageCodes) } + private fun Type.recompute(allowedLanguageLocales: Set): Type? { + val updatedEntries = entryList.mapNotNull { it.recompute(allowedLanguageLocales) } return if (updatedEntries.isNotEmpty()) { toBuilder().apply { clearEntry() @@ -129,8 +133,10 @@ private class FilterPerLanguageResources { } else null } - private fun Entry.recompute(allowedLanguageCodes: Set): Entry? { - val updatedConfigValues = configValueList.filter { it.isKept(allowedLanguageCodes) } + private fun Type.countResources(): Int = entryList.sumOf { it.configValueCount } + + private fun Entry.recompute(allowedLanguageLocales: Set): Entry? { + val updatedConfigValues = configValueList.filter { it.isKept(allowedLanguageLocales) } return if (updatedConfigValues.isNotEmpty()) { toBuilder().apply { clearConfigValue() @@ -139,18 +145,75 @@ private class FilterPerLanguageResources { } else null } - private fun ConfigValue.isKept(allowedLanguageCodes: Set) = - config.locale in allowedLanguageCodes - - private fun LanguageSupportDefinition.toAndroidBcp47Locale(): String? { - val androidLanguageId = appStringId.androidResourcesLanguageId - val language = androidLanguageId.languageCode.toLowerCase(Locale.US) - val region = androidLanguageId.regionCode.toUpperCase(Locale.US) - return when { - language.isEmpty() -> null // Unsupported. - language == "en" -> "" // English is the default language code on Android. - region.isEmpty() -> language - else -> "$language-$region" + private fun ConfigValue.isKept(allowedLanguageLocales: Set) = + LanguageLocale.createFrom(config.locale) in allowedLanguageLocales + + /** Represents a locale in which text may be translated to a specific language. */ + private sealed class LanguageLocale { + /** The IETF BCP 47 language code representation for this locale. */ + abstract val bcp47QualifiedCode: String + + /** + * The Android-specific IETF BCP 47 language code representation for this locale (which can vary + * from [bcp47QualifiedCode] since Android doesn't exactly conform to IETF BCP 47). + */ + abstract val androidBcp47QualifiedCode: String + + /** + * Locale corresponding to a language that has no regional-specific ties. + * + * @property languageCode the 2-character identifier code corresponding to the language + */ + private data class GlobalLanguage(val languageCode: String) : LanguageLocale() { + override val bcp47QualifiedCode = languageCode + override val androidBcp47QualifiedCode: String + get() = if (languageCode == "en") "" else languageCode + } + + /** + * Locale corresponding to a language with regionally-affected translations. + * + * @property globalLanguage the language's representation globally + * @property regionCode the 2-character region code corresponding to the [globalLanguage] + */ + private data class RegionalLanguage( + val globalLanguage: GlobalLanguage, + val regionCode: String + ) : LanguageLocale() { + override val bcp47QualifiedCode = + "${globalLanguage.bcp47QualifiedCode}-${regionCode.uppercase()}" + override val androidBcp47QualifiedCode = + "${globalLanguage.androidBcp47QualifiedCode}-${regionCode.uppercase()}" + } + + companion object { + /** + * Returns a new [LanguageLocale] from the provided [qualifiedLanguageCode] (which may be + * either IETF BCP-47 or the Android version of it). + */ + fun createFrom(qualifiedLanguageCode: String): LanguageLocale { + return if ("-" in qualifiedLanguageCode) { + val (languageCode, regionCode) = qualifiedLanguageCode.split('-', limit = 2) + RegionalLanguage(createGlobalLanguageLocale(languageCode), regionCode.lowercase()) + } else createGlobalLanguageLocale(qualifiedLanguageCode) + } + + /** Returns a new [LanguageLocale] to represent the provided [definition]. */ + fun createFrom(definition: LanguageSupportDefinition): LanguageLocale? { + val androidLanguageId = definition.appStringId.androidResourcesLanguageId + val language = androidLanguageId.languageCode.lowercase() + val region = androidLanguageId.regionCode.lowercase() + return when { + language.isEmpty() -> null // Unsupported. + region.isEmpty() -> GlobalLanguage(language) + else -> RegionalLanguage(GlobalLanguage(language), region) + } + } + + private fun createGlobalLanguageLocale(languageCode: String): GlobalLanguage { + return languageCode.lowercase().takeIf(String::isNotEmpty)?.let(::GlobalLanguage) + ?: GlobalLanguage(languageCode = "en") + } } } } diff --git a/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt b/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt index 915b506ce0f..5bf6035b2bf 100644 --- a/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt +++ b/scripts/src/java/org/oppia/android/scripts/ci/ComputeAffectedTests.kt @@ -70,7 +70,7 @@ fun main(args: Array) { // Needed since the codebase isn't yet using Kotlin 1.5, so this function isn't available. private fun String.toBooleanStrictOrNull(): Boolean? { - return when (toLowerCase(Locale.US)) { + return when (lowercase(Locale.US)) { "false" -> false "true" -> true else -> null @@ -121,7 +121,7 @@ class ComputeAffectedTests( println("Current branch: ${gitClient.currentBranch}.") println("Most recent common commit: ${gitClient.branchMergeBase}.") - val currentBranch = gitClient.currentBranch.toLowerCase(Locale.US) + val currentBranch = gitClient.currentBranch.lowercase(Locale.US) val affectedTestTargets = if (computeAllTestsSetting || currentBranch == "develop") { computeAllTestTargets(bazelClient) } else computeAffectedTargetsForNonDevelopBranch(gitClient, bazelClient, rootDirectory) diff --git a/scripts/src/java/org/oppia/android/scripts/telemetry/DecodeUserStudyEventString.kt b/scripts/src/java/org/oppia/android/scripts/telemetry/DecodeUserStudyEventString.kt index 479b38baff8..83b69e7b84b 100644 --- a/scripts/src/java/org/oppia/android/scripts/telemetry/DecodeUserStudyEventString.kt +++ b/scripts/src/java/org/oppia/android/scripts/telemetry/DecodeUserStudyEventString.kt @@ -99,9 +99,9 @@ class DecodeUserStudyEventString { } private companion object { - private const val CARRIAGE_RETURN = '\r'.toInt() - private const val NEW_LINE = '\n'.toInt() - private const val SPACE = ' '.toInt() + private const val CARRIAGE_RETURN = '\r'.code + private const val NEW_LINE = '\n'.code + private const val SPACE = ' '.code private val base64Decoder by lazy { Base64.getDecoder() } private inline fun InputStream.fromCompressedBase64(baseMessage: M): M { diff --git a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt index cc759f7cc3e..4e96123650e 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt @@ -33,7 +33,8 @@ class RegexPatternValidationCheckTest { "file_content_validation_checks.textproto." private val settableFutureUsageErrorMessage = "SettableFuture should only be used in pre-approved locations since it's easy to potentially " + - "mess up & lead to a hanging ListenableFuture." + "mess up & lead to a hanging ListenableFuture. If using a Deferred, convert it to a " + + "ListenableFuture using asListenableFuture()." private val androidLayoutIncludeTagErrorMessage = "Remove tag from layouts and instead use the widget directly, e.g. AppBarLayout." private val androidGravityLeftErrorMessage = diff --git a/testing/build.gradle b/testing/build.gradle index 834206b8704..7add13a2b3d 100644 --- a/testing/build.gradle +++ b/testing/build.gradle @@ -74,16 +74,17 @@ dependencies { 'androidx.test.espresso:espresso-core:3.2.0', 'androidx.test:runner:1.2.0', 'com.google.android.material:material:1.3.0', - 'com.google.dagger:dagger:2.24', + 'com.google.dagger:dagger:2.41', 'com.google.firebase:firebase-auth-ktx:19.3.1', 'com.google.protobuf:protobuf-javalite:3.17.3', 'com.google.truth:truth:1.1.3', 'com.google.truth.extensions:truth-liteproto-extension:1.1.3', 'nl.dionsegijn:konfetti:1.2.5', - 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2', + 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4', 'org.robolectric:robolectric:4.5', 'org.jetbrains.kotlin:kotlin-reflect:$kotlin_version', 'org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version', + 'org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.6.4', 'org.mockito:mockito-core:2.19.0', project(":domain"), project(":model"), @@ -105,10 +106,10 @@ dependencies { project(":domain"), ) kapt( - 'com.google.dagger:dagger-compiler:2.24', + 'com.google.dagger:dagger-compiler:2.41', ) kaptTest( - 'com.google.dagger:dagger-compiler:2.24', + 'com.google.dagger:dagger-compiler:2.41', ) annotationProcessor( 'com.google.auto.service:auto-service:1.0-rc4', diff --git a/testing/src/main/java/org/oppia/android/testing/junit/OppiaParameterizedTestRunner.kt b/testing/src/main/java/org/oppia/android/testing/junit/OppiaParameterizedTestRunner.kt index ae5e3e5f55c..03e5516fe7c 100644 --- a/testing/src/main/java/org/oppia/android/testing/junit/OppiaParameterizedTestRunner.kt +++ b/testing/src/main/java/org/oppia/android/testing/junit/OppiaParameterizedTestRunner.kt @@ -10,7 +10,6 @@ import org.junit.runner.manipulation.Sortable import org.junit.runner.manipulation.Sorter import org.junit.runner.notification.RunNotifier import org.junit.runners.Suite -import java.lang.annotation.Repeatable import java.lang.reflect.Field import java.lang.reflect.Method import kotlin.reflect.KClass @@ -30,10 +29,10 @@ import kotlin.reflect.KClass * necessary Bazel dependencies). However, it will only support the platform(s) selected. * * To introduce parameterized tests, add this runner along with one or more [Parameter]-annotated - * fields and one or more [RunParameterized]-annotated methods (where each method should have - * multiple [Iteration]s defined to describe each test iteration). Note that only strings and - * primitive types (e.g. [Int], [Long], [Float], [Double], and [Boolean]) are supported for - * parameter injection. Here's a simple example: + * fields and one or more [Iteration]-annotated methods (where each method should have multiple + * [Iteration]s defined to describe each test iteration). Note that only strings and primitive types + * (e.g. [Int], [Long], [Float], [Double], and [Boolean]) are supported for parameter injection. + * Here's a simple example: * * ```kotlin * @RunWith(OppiaParameterizedTestRunner::class) @@ -43,11 +42,9 @@ import kotlin.reflect.KClass * @Parameter var intParam: Int = Int.MIN_VALUE // Inited because primitives can't be lateinit. * * @Test - * @RunParameterized( - * Iteration("first", "strParam=first value", "intParam=12"), - * Iteration("second", "strParam=second value", "intParam=-72"), - * Iteration("third", "strParam=third value", "intParam=15") - * ) + * @Iteration("first", "strParam=first value", "intParam=12") + * @Iteration("second", "strParam=second value", "intParam=-72") + * @Iteration("third", "strParam=third value", "intParam=15") * fun testParams_multipleVals_isConsistent() { * val result = performOperation(strParam, intParam) * assertThat(result).isEqualTo(consistentExpectedValue) @@ -59,7 +56,7 @@ import kotlin.reflect.KClass * specified parameter value corresponding to each iteration will be injected into the parameter * field for use by the test. * - * Note that with Bazel specific iterations can be run by utilizing the test and iteration name, + * Note that with Bazel specifically iterations can be run by utilizing the test and iteration name, * e.g.: * * ```bash @@ -73,10 +70,9 @@ import kotlin.reflect.KClass * ``` * * Finally, regular tests can be added by simply using the JUnit ``Test`` annotation without also - * annotating with [RunParameterized]. Such tests should not ever read from the - * [Parameter]-annotated fields since there's no way to ensure what values those fields will - * contain (thus they should be treated as undefined outside of tests that specific define their - * value via [Iteration]). + * annotating with [Iteration]. Such tests should not ever read from the [Parameter]-annotated + * fields since there's no way to ensure what values those fields will contain (thus they should be + * treated as undefined outside of tests that specific define their value via [Iteration]). */ @RequiresApi(Build.VERSION_CODES.N) class OppiaParameterizedTestRunner(private val testClass: Class<*>) : Suite(testClass, listOf()) { @@ -249,17 +245,7 @@ class OppiaParameterizedTestRunner(private val testClass: Class<*>) : Suite(test @Target(AnnotationTarget.FIELD) annotation class Parameter /** - * Specifies that a method in a test that uses a [OppiaParameterizedTestRunner] runner should be - * run multiple times for each [Iteration] specified in the [value] iterations list. - * - * See the KDoc for the runner for example code. - */ - @Target(AnnotationTarget.FUNCTION) annotation class RunParameterized(vararg val value: Iteration) - - // TODO(#4120): Migrate to Kotlin @Repeatable once Kotlin 1.6 is used (see: - // https://youtrack.jetbrains.com/issue/KT-12794). - /** - * Defines an iteration to run as part of a [RunParameterized]-annotated test method. + * Defines an iteration to run as part of a parameterized test method. * * See the KDoc for the runner for example code. * @@ -269,7 +255,7 @@ class OppiaParameterizedTestRunner(private val testClass: Class<*>) : Suite(test * a [Parameter]-annotated field and 'value' is a stringified conforming value based on the * type of that field (incompatible values will result in test failures) */ - @Repeatable(RunParameterized::class) + @Repeatable @Target(AnnotationTarget.FUNCTION) annotation class Iteration(val name: String, vararg val keyValuePairs: String) diff --git a/testing/src/main/java/org/oppia/android/testing/junit/ParameterizedMethod.kt b/testing/src/main/java/org/oppia/android/testing/junit/ParameterizedMethod.kt index 433b9241607..7e02448e96d 100644 --- a/testing/src/main/java/org/oppia/android/testing/junit/ParameterizedMethod.kt +++ b/testing/src/main/java/org/oppia/android/testing/junit/ParameterizedMethod.kt @@ -32,8 +32,10 @@ class ParameterizedMethod( // changes). val baseClass = testClassInstance.javaClass val fieldSetters = parameterFields.associate { field -> - val setterMethod = - baseClass.getDeclaredMethod("set${field.name.capitalize(Locale.US)}", field.type) + val fieldName = field.name.replaceFirstChar { + if (it.isLowerCase()) it.titlecase(Locale.US) else it.toString() + } + val setterMethod = baseClass.getDeclaredMethod("set$fieldName", field.type) field.name to setterMethod } values.getValue(iterationName).forEach { parameterValue -> diff --git a/testing/src/main/java/org/oppia/android/testing/threading/BUILD.bazel b/testing/src/main/java/org/oppia/android/testing/threading/BUILD.bazel index 700ed274b87..0b03b47d22c 100644 --- a/testing/src/main/java/org/oppia/android/testing/threading/BUILD.bazel +++ b/testing/src/main/java/org/oppia/android/testing/threading/BUILD.bazel @@ -92,6 +92,7 @@ kt_android_library( deps = [ "//third_party:androidx_annotation_annotation", "//third_party:org_jetbrains_kotlinx_kotlinx-coroutines-core", + "//third_party:org_jetbrains_kotlinx_kotlinx-coroutines-guava", ], ) diff --git a/testing/src/main/java/org/oppia/android/testing/threading/CoroutineExecutorService.kt b/testing/src/main/java/org/oppia/android/testing/threading/CoroutineExecutorService.kt index b3d8f41f915..0c4f2f676e5 100644 --- a/testing/src/main/java/org/oppia/android/testing/threading/CoroutineExecutorService.kt +++ b/testing/src/main/java/org/oppia/android/testing/threading/CoroutineExecutorService.kt @@ -11,9 +11,9 @@ import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.guava.asListenableFuture import kotlinx.coroutines.runBlocking import kotlinx.coroutines.selects.select -import kotlinx.coroutines.withTimeout import kotlinx.coroutines.withTimeoutOrNull import java.util.concurrent.Callable import java.util.concurrent.ExecutionException @@ -77,7 +77,7 @@ class CoroutineExecutorService( } override fun submit(task: Callable?): Future { - return dispatchAsync(task ?: throw NullPointerException()).toFuture() + return dispatchAsync(task ?: throw NullPointerException()).asListenableFuture() } override fun submit(task: Runnable?, result: T): Future { @@ -93,7 +93,7 @@ class CoroutineExecutorService( } override fun submit(task: Runnable?): Future<*> { - return dispatchAsync(task ?: throw NullPointerException()).toFuture() + return dispatchAsync(task ?: throw NullPointerException()).asListenableFuture() } override fun shutdownNow(): MutableList { @@ -213,7 +213,7 @@ class CoroutineExecutorService( null } } - val future = task.toFuture() + val future = task.asListenableFuture() if (result == null && timeoutMillis > 0) { // Cancel the operation if it's taking too long, but only if there's a timeout set. This // won't cancel the future if the deferred is completed with a failure, or passing with a @@ -299,54 +299,7 @@ class CoroutineExecutorService( private data class Task(val runnable: Runnable, val deferred: Deferred) - /** - * Returns a new [Future] based on a [Deferred]. Note that the APIs between these two async - * constructs are different, so there may be some subtle inconsistencies in practice. - */ - private fun Deferred.toFuture(): Future { - val deferred: Deferred = this - return object : Future { - override fun isDone(): Boolean = deferred.isCompleted - - override fun get(): T = get(/* timeout= */ 0, TimeUnit.MILLISECONDS) - - override fun get(timeout: Long, unit: TimeUnit?): T { - return runBlocking { - try { - maybeWithTimeout(unit?.toMillis(timeout) ?: 0) { - deferred.await() - } - } catch (e: Exception) { - // Rethrow the failure if the computation failed. - throw ExecutionException(e) - } - } - } - - override fun cancel(mayInterruptIfRunning: Boolean): Boolean { - return if (!deferred.isCompleted) { - deferred.cancel() - true - } else { - false - } - } - - override fun isCancelled(): Boolean = deferred.isCancelled - } - } - private companion object { - /** - * Wraps the specified block in a withTimeout() only if the specified timeout is larger than 0. - */ - private suspend fun maybeWithTimeout( - timeoutMillis: Long, - block: TimeoutBlock - ): T { - return maybeWithTimeoutDelegated(timeoutMillis, block, ::withTimeout) - } - /** * Wraps the specified block in a withTimeoutOrNull() only if the specified timeout is larger * than 0. @@ -355,18 +308,10 @@ class CoroutineExecutorService( timeoutMillis: Long, block: TimeoutBlock ): T? { - return maybeWithTimeoutDelegated(timeoutMillis, block, ::withTimeoutOrNull) - } - - private suspend fun maybeWithTimeoutDelegated( - timeoutMillis: Long, - block: TimeoutBlock, - withTimeoutDelegate: suspend (Long, TimeoutBlock) -> R - ): R { return coroutineScope { if (timeoutMillis > 0) { try { - withTimeoutDelegate(timeoutMillis, block) + withTimeoutOrNull(timeoutMillis, block) } catch (e: TimeoutCancellationException) { // Treat timeouts in this service as a standard TimeoutException (which should result in // the coroutine being completed with a failure). diff --git a/testing/src/test/java/org/oppia/android/testing/logging/TestSyncStatusManagerTest.kt b/testing/src/test/java/org/oppia/android/testing/logging/TestSyncStatusManagerTest.kt index e20b1fd1b62..e92463a7982 100644 --- a/testing/src/test/java/org/oppia/android/testing/logging/TestSyncStatusManagerTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/logging/TestSyncStatusManagerTest.kt @@ -20,7 +20,6 @@ import org.oppia.android.testing.data.DataProviderTestMonitor import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.networking.NetworkConnectionTestUtil @@ -199,14 +198,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_forceStatus_noConnectivity_returnsForcedStatus() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -221,14 +218,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_forceStatus_noEvents_returnsForcedStatus() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -243,14 +238,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_forceStatus_withEvents_returnsForcedStatus() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -267,14 +260,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_forceStatus_withEvents_allRemoved_returnsForcedStatus() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -293,14 +284,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogs_forceStatus_reportUploadingStarted_returnsForcedStatus() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -317,14 +306,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_forceStatus_reportUploadingEnded_returnsForcedStatus() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -344,14 +331,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_forceStatus_reportError_returnsForcedStatus() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -367,14 +352,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_initialState_resetStatus_returnsInitialUnknown() { val syncStatusProvider = impl.getSyncStatus() impl.forceSyncStatus(syncStatus) @@ -389,14 +372,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_resetStatus_noConnectivity_returnsNoConnectivity() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -414,14 +395,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_resetStatus_noEvents_returnsInitialUnknown() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -438,14 +417,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_resetStatus_withEvents_returnsWaitingToStartUploading() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -464,14 +441,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_resetStatus_withEvents_allRemoved_returnsDataUploaded() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -492,14 +467,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_resetStatus_reportUploadingStarted_returnsUploading() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -518,14 +491,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_resetStatus_reportUploadingEnded_returnsUploaded() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -546,14 +517,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatus_withInitedLogStore_resetStatus_reportError_returnsUploadError() { val syncStatusProvider = impl.getSyncStatus() impl.initializeEventLogStore(logsCacheStore) @@ -745,14 +714,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatuses_initialState_forceStatus_returnsWithForcedStatus() { impl.forceSyncStatus(syncStatus) testCoroutineDispatchers.runCurrent() @@ -764,14 +731,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatuses_withInitedLogStore_forceStatus_noConnectivity_returnsWithForcedStatus() { impl.initializeEventLogStore(logsCacheStore) disconnectNetwork() @@ -785,14 +750,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatuses_withInitedLogStore_forceStatus_noEvents_returnsWithForcedStatus() { impl.initializeEventLogStore(logsCacheStore) connectNetwork() @@ -806,14 +769,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatuses_withInitedLogStore_forceStatus_withEvents_returnsWithForcedStatus() { impl.initializeEventLogStore(logsCacheStore) connectNetwork() @@ -829,14 +790,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatuses_withLogStore_forceStatus_withEvents_allRemoved_returnsWithForcedStatus() { impl.initializeEventLogStore(logsCacheStore) connectNetwork() @@ -854,14 +813,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatuses_withLogStore_forceStatus_reportUploading_returnsWithForcedStatus() { impl.initializeEventLogStore(logsCacheStore) connectNetwork() @@ -878,14 +835,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatuses_withLogStore_forceStatus_reportUploadingEnded_returnsWithForcedStatus() { impl.initializeEventLogStore(logsCacheStore) connectNetwork() @@ -905,14 +860,12 @@ class TestSyncStatusManagerTest : SyncStatusManagerTestBase() { } @Test - @RunParameterized( - Iteration("initial_unknown", "status=INITIAL_UNKNOWN"), - Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING"), - Iteration("data_uploading", "status=DATA_UPLOADING"), - Iteration("data_uploaded", "status=DATA_UPLOADED"), - Iteration("no_connectivity", "status=NO_CONNECTIVITY"), - Iteration("upload_error", "status=UPLOAD_ERROR") - ) + @Iteration("initial_unknown", "status=INITIAL_UNKNOWN") + @Iteration("waiting_to_start_uploading", "status=WAITING_TO_START_UPLOADING") + @Iteration("data_uploading", "status=DATA_UPLOADING") + @Iteration("data_uploaded", "status=DATA_UPLOADED") + @Iteration("no_connectivity", "status=NO_CONNECTIVITY") + @Iteration("upload_error", "status=UPLOAD_ERROR") fun testGetSyncStatuses_withInitedLogStore_forceStatus_reportError_returnsWithForcedStatus() { impl.initializeEventLogStore(logsCacheStore) connectNetwork() diff --git a/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt b/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt index 65a3853a21c..eff9a83d856 100644 --- a/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt +++ b/testing/src/test/java/org/oppia/android/testing/threading/CoroutineExecutorServiceTest.kt @@ -339,8 +339,8 @@ class CoroutineExecutorServiceTest { val getResult = testDispatcherScope.async { try { - AsyncResult.Success(callableFuture.get(/* timeout= */ 1, TimeUnit.SECONDS)) - } catch (e: ExecutionException) { + AsyncResult.Success(callableFuture.get(/* timeout = */ 1, TimeUnit.SECONDS)) + } catch (e: Exception) { AsyncResult.Failure(e) } } @@ -349,8 +349,7 @@ class CoroutineExecutorServiceTest { // The getter should return since the task has finished. assertThat(getResult.isCompleted).isTrue() assertThat(getResult.getCompleted()).isFailureThat().apply { - isInstanceOf(ExecutionException::class.java) - hasCauseThat().isInstanceOf(TimeoutException::class.java) + isInstanceOf(TimeoutException::class.java) } } diff --git a/third_party/BUILD.bazel b/third_party/BUILD.bazel index b5d742b46f7..f45d5300cd6 100644 --- a/third_party/BUILD.bazel +++ b/third_party/BUILD.bazel @@ -12,6 +12,7 @@ own Bazel macros to automatically set up code generation (which includes pulling dependencies). """ +load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_import", "kt_jvm_library") load("@rules_java//java:defs.bzl", "java_binary", "java_library") load("@rules_jvm_external//:defs.bzl", "artifact") load(":versions.bzl", "MAVEN_PRODUCTION_DEPENDENCY_VERSIONS", "MAVEN_TEST_DEPENDENCY_VERSIONS") @@ -70,7 +71,6 @@ java_library( visibility = ["//visibility:public"], exports = [ "//third_party:com_squareup_moshi_moshi-kotlin", - "//third_party:com_squareup_moshi_moshi-kotlin-codegen", ], ) @@ -110,6 +110,51 @@ android_library( ], ) +# Note that the output from kt_jvm_import needs to be wrapped in a kt_jvm_library in order to work +# with the Bazel IntelliJ plugin correctly (since kt_jvm_library provides the expected IDE output +# for syncing). +kt_jvm_import( + name = "_kotlinx-coroutines-core-jvm_import_do_not_depend", + jars = ["@kotlinx-coroutines-core-jvm//jar:file"], + tags = ["no-ide"], + deps = [ + ":_stopgap_lib_for_kotlinx_coroutines_desugar_do_not_depend", + "//third_party:org_jetbrains_kotlin_kotlin-stdlib-jdk8_jar", + ], +) + +kt_jvm_library( + name = "kotlinx-coroutines-core-jvm", + visibility = [ + "//:oppia_api_visibility", + "@maven//:__subpackages__", + ], + exports = [":_kotlinx-coroutines-core-jvm_import_do_not_depend"], +) + +# This solution is based on https://github.com/Bencodes/bazel_issue_13553 for Bazel issue: +# https://github.com/bazelbuild/bazel/issues/13553. +genrule( + name = "_generate_stopgap_files_for_kotlinx_coroutines_desugar", + outs = [ + "sun/misc/Signal.java", + "sun/misc/SignalHandler.java", + ], + cmd = """ + echo "package sun.misc; public final class Signal {}" > $(location sun/misc/Signal.java) + echo "package sun.misc; public interface SignalHandler {}" > $(location sun/misc/SignalHandler.java) + """, +) + +java_library( + name = "_stopgap_lib_for_kotlinx_coroutines_desugar_do_not_depend", + srcs = [ + "sun/misc/Signal.java", + "sun/misc/SignalHandler.java", + ], + neverlink = True, +) + # Define a separate target for the Glide annotation processor compiler. Unfortunately, this library # can't encapsulate all of Glide (i.e. by exporting the main Glide dependency) since that includes # Android assets which java_library targets do not export. diff --git a/third_party/maven_install.json b/third_party/maven_install.json index 396db58c5e9..6af4aaf5b4c 100644 --- a/third_party/maven_install.json +++ b/third_party/maven_install.json @@ -1,7 +1,7 @@ { "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", - "__INPUT_ARTIFACTS_HASH": 2017630185, - "__RESOLVED_ARTIFACTS_HASH": -1490224642, + "__INPUT_ARTIFACTS_HASH": -519121942, + "__RESOLVED_ARTIFACTS_HASH": -749919456, "conflict_resolution": { "androidx.constraintlayout:constraintlayout:1.1.3": "androidx.constraintlayout:constraintlayout:2.0.1", "androidx.core:core:1.0.1": "androidx.core:core:1.3.1", @@ -11,29 +11,11 @@ "com.google.protobuf:protobuf-javalite:3.17.3": "com.google.protobuf:protobuf-javalite:3.19.2", "com.google.truth:truth:0.43": "com.google.truth:truth:1.1.3", "junit:junit:4.12": "junit:junit:4.13.2", - "org.jetbrains.kotlin:kotlin-reflect:1.3.41": "org.jetbrains.kotlin:kotlin-reflect:1.5.0", - "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72": "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32", + "org.jetbrains.kotlin:kotlin-reflect:1.3.41": "org.jetbrains.kotlin:kotlin-reflect:1.6.0", + "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10": "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21", "org.mockito:mockito-core:2.19.0": "org.mockito:mockito-core:3.9.0" }, "artifacts": { - "android.arch.core:common": { - "shasums": { - "jar": "3a616a32f433e9e23f556b38575c31b013613d3ae85206263b7625fe1f4c151a" - }, - "version": "1.1.1" - }, - "android.arch.core:core-testing:aar": { - "shasums": { - "jar": "150a6f028af6c57ca6de66cb185a135cdcf737f597443acc4cf8aeeec064fff3" - }, - "version": "1.1.1" - }, - "android.arch.core:runtime:aar": { - "shasums": { - "jar": "c3215aa5873311b3f88a6f4e4a3c25ad89971bc127de8c3e1291c57f93a05c39" - }, - "version": "1.1.1" - }, "androidx.activity:activity:aar": { "shasums": { "jar": "4f2b35916768032f7d0c20e250e28b29037ed4ce9ebf3da4fcd51bcb0c6067ef" @@ -532,12 +514,6 @@ }, "version": "3.4.2" }, - "com.android.support:support-annotations": { - "shasums": { - "jar": "5d5b9414f02d3fa0ee7526b8d5ddae0da67c8ecc8c4d63ffa6cf91488a93b927" - }, - "version": "28.0.0" - }, "com.android.tools.build.jetifier:jetifier-core": { "shasums": { "jar": "c9f8b016144cfb31c5aee92d47f34de23289167cac5e8ef68365b2dd05766f11" @@ -738,9 +714,9 @@ }, "com.google.auto.service:auto-service-annotations": { "shasums": { - "jar": "986dc826fa0a43bf9f04194c1a8667774f4f44190ec816b08554b47891ba5459" + "jar": "44752893119fdaf01b4c5ee74e46e5dab86f2dcda18114c562f877355c6ed26e" }, - "version": "1.0-rc7" + "version": "1.0" }, "com.google.auto.value:auto-value-annotations": { "shasums": { @@ -1020,21 +996,21 @@ }, "com.squareup.moshi:moshi": { "shasums": { - "jar": "b6ee64fb84a7486aa9983e20c75259d4931bd597c169e1e67c3bc0521fd03b27" + "jar": "bd004dd9ba175e603ad44420bf605250291b9b7bc6b9d9e916f5741ac8663307" }, - "version": "1.11.0" + "version": "1.13.0" }, "com.squareup.moshi:moshi-kotlin": { "shasums": { - "jar": "220f3b85d99ea40ff65609813f3624fb4313de3634a747adb04040cf7cb486bc" + "jar": "a4967678345569919986c0d71ad59ae615745f708ae19fce30ba1e2bcb7f60cd" }, - "version": "1.11.0" + "version": "1.13.0" }, "com.squareup.moshi:moshi-kotlin-codegen": { "shasums": { - "jar": "e5d8e5cba11d8aca0261649c362fdee718e16ccc647124e55ee2e2c328be4c82" + "jar": "2cab2ee6ff25c12e2712bacbf170239335b3d4694398a5aeddb39484856fd1ae" }, - "version": "1.11.0" + "version": "1.13.0" }, "com.squareup.okhttp3:mockwebserver": { "shasums": { @@ -1056,9 +1032,9 @@ }, "com.squareup.okio:okio": { "shasums": { - "jar": "4d84ef686277b58eb05691ac19cd3befa3429a27274982ee65ea0f07044bcc00" + "jar": "a27f091d34aa452e37227e2cfa85809f29012a8ef2501a9b5a125a978e4fcbc1" }, - "version": "2.6.0" + "version": "2.10.0" }, "com.squareup.retrofit2:converter-moshi": { "shasums": { @@ -1092,9 +1068,9 @@ }, "com.squareup:kotlinpoet": { "shasums": { - "jar": "8085eb4c8b1ece4f32259b22f26bf880bc47b74f548e29010b0146aa6b38f24b" + "jar": "336095fd910caeaebcc2f6998df6625a9a90a5fd9f2cfa215ac224b77f37fbc6" }, - "version": "1.6.0" + "version": "1.10.2" }, "commons-codec:commons-codec": { "shasums": { @@ -1206,9 +1182,9 @@ }, "net.ltgt.gradle.incap:incap": { "shasums": { - "jar": "1d3ebe10d6059a26438dd183ab5a823cf8cd8081bc0d4cf997ad80e9ab9607d8" + "jar": "b625b9806b0f1e4bc7a2e3457119488de3cd57ea20feedd513db070a573a4ffd" }, - "version": "0.3" + "version": "0.2" }, "net.sf.kxml:kxml2": { "shasums": { @@ -1296,9 +1272,9 @@ }, "org.jetbrains.kotlin:kotlin-reflect": { "shasums": { - "jar": "e30acc4ff74534177d1657feafb57327ede838ae17763aeaae182a9109d26157" + "jar": "c6161884209221db7f5ddb031bb480a3c46bb90d5b65d7cc0167b149aaa9c494" }, - "version": "1.5.0" + "version": "1.6.0" }, "org.jetbrains.kotlin:kotlin-script-runtime": { "shasums": { @@ -1308,27 +1284,27 @@ }, "org.jetbrains.kotlin:kotlin-stdlib": { "shasums": { - "jar": "452d205f54a1f08673de273cb3d0148fbf9cd95275e5b0068fa1b001f48aee0a" + "jar": "739c526672bb337573b28f63afa8306eb088b0c3a0967f56d6c89f4a3012a492" }, - "version": "1.5.32" + "version": "1.6.21" }, "org.jetbrains.kotlin:kotlin-stdlib-common": { "shasums": { - "jar": "dc2fb23e280a39c9abde2cbf4c1567b66840f1f1ece6c7bb78d58d38076b5def" + "jar": "183bec59cd9f3a14957b190e8c879cf1194bd1f106b0a7b6e1cbb8790d242363" }, - "version": "1.5.32" + "version": "1.6.21" }, "org.jetbrains.kotlin:kotlin-stdlib-jdk7": { "shasums": { - "jar": "bc954cd528b97cc25b8110686bda8af95cfcdb0dba0f3f68d0bb7c2d30d2c504" + "jar": "f1b0634dbb94172038463020bb2dd45ca26849f8ce29d625acb0f1569d11dbee" }, - "version": "1.5.32" + "version": "1.6.21" }, "org.jetbrains.kotlin:kotlin-stdlib-jdk8": { "shasums": { - "jar": "fe6837926a93a36f76550631d552dcf98046d96888a4ffd0c939e33296a3d9e5" + "jar": "dab45489b47736d59fce44b80676f1947a9b6bcab10fd60e878a83bd82a6954c" }, - "version": "1.5.32" + "version": "1.6.21" }, "org.jetbrains.kotlin:kotlin-test": { "shasums": { @@ -1356,33 +1332,39 @@ }, "org.jetbrains.kotlinx:kotlinx-coroutines-android": { "shasums": { - "jar": "d4cadb673b2101f1ee5fbc147956ac78b1cfd9cc255fb53d3aeb88dff11d99ca" + "jar": "3fdc0eed5bc4b83ee9622774520a2db25470370eacd1581cac1e37704f095b00" }, - "version": "1.4.1" + "version": "1.6.4" }, "org.jetbrains.kotlinx:kotlinx-coroutines-core": { "shasums": { - "jar": "de487d57b156e4e237abbc9cf7fff8777b2495aff6caa8bc4e9cf6ec859f0224" + "jar": "778851e73851b502e8366434bc9ec58371431890fb12b89e7edbf1732962c030" }, - "version": "1.4.3" + "version": "1.6.4" }, "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm": { "shasums": { - "jar": "f7be08ddf86bd88020da7b78adbf44228799cca54d5c0c4396d850bc66725163" + "jar": "c24c8bb27bb320c4a93871501a7e5e0c61607638907b197aef675513d4c820be" }, - "version": "1.4.3" + "version": "1.6.4" }, - "org.jetbrains.kotlinx:kotlinx-coroutines-debug": { + "org.jetbrains.kotlinx:kotlinx-coroutines-guava": { "shasums": { - "jar": "6a92f46fe713e9cade9cf55489844b0acf38596a070c1c85f0580e8107ae485e" + "jar": "94deeee072e0f762a8a3ccc66b1762c5d96d55eca13cab4001f5b7588bb74390" }, - "version": "1.2.2" + "version": "1.6.4" }, "org.jetbrains.kotlinx:kotlinx-coroutines-test": { "shasums": { - "jar": "31e03c48a2f63ee11ee4d1eed4c1a19f561531e838525c67346f4bacdd422444" + "jar": "993eef7de86d59e99096fbc51b7df33f0cc8a3a655e195590765b7e51e4c0aaa" }, - "version": "1.2.2" + "version": "1.6.4" + }, + "org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm": { + "shasums": { + "jar": "69d65e5fea41cbc0bb905d3ef6623a2348b931fd01b9f2c4a1751a372f2e476d" + }, + "version": "1.6.4" }, "org.jetbrains.kotlinx:kotlinx-metadata-jvm": { "shasums": { @@ -1416,9 +1398,9 @@ }, "org.ow2.asm:asm": { "shasums": { - "jar": "cda4de455fab48ff0bcb7c48b4639447d4de859a7afc30a094a986f0936beba2" + "jar": "b9d4fe4d71938df38839f0eca42aaaa64cf8b313d678da036f0cb3ca199b47f5" }, - "version": "9.1" + "version": "9.2" }, "org.ow2.asm:asm-analysis": { "shasums": { @@ -1518,19 +1500,6 @@ } }, "dependencies": { - "android.arch.core:common": [ - "com.android.support:support-annotations" - ], - "android.arch.core:core-testing:aar": [ - "android.arch.core:runtime:aar", - "com.android.support:support-annotations", - "junit:junit", - "org.mockito:mockito-core" - ], - "android.arch.core:runtime:aar": [ - "android.arch.core:common", - "com.android.support:support-annotations" - ], "androidx.activity:activity:aar": [ "androidx.annotation:annotation", "androidx.core:core:aar", @@ -2290,18 +2259,19 @@ "org.ow2.asm:asm" ], "com.squareup.moshi:moshi": [ - "com.squareup.okio:okio" + "com.squareup.okio:okio", + "org.jetbrains.kotlin:kotlin-stdlib-jdk8" ], "com.squareup.moshi:moshi-kotlin": [ "com.squareup.moshi:moshi", "org.jetbrains.kotlin:kotlin-reflect", - "org.jetbrains.kotlin:kotlin-stdlib" + "org.jetbrains.kotlin:kotlin-stdlib-jdk8" ], "com.squareup.moshi:moshi-kotlin-codegen": [ "com.google.auto.service:auto-service-annotations", + "com.google.guava:guava", "com.squareup.moshi:moshi", "com.squareup:kotlinpoet", - "net.ltgt.gradle.incap:incap", "org.jetbrains.kotlin:kotlin-reflect", "org.jetbrains.kotlin:kotlin-stdlib-jdk8", "org.ow2.asm:asm" @@ -2424,20 +2394,28 @@ "org.jetbrains.kotlin:kotlin-test-annotations-common" ], "org.jetbrains.kotlinx:kotlinx-coroutines-android": [ - "org.jetbrains.kotlin:kotlin-stdlib", - "org.jetbrains.kotlinx:kotlinx-coroutines-core" + "org.jetbrains.kotlin:kotlin-stdlib-jdk8", + "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm" ], "org.jetbrains.kotlinx:kotlinx-coroutines-core": [ "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm" ], "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm": [ - "org.jetbrains.kotlin:kotlin-stdlib", - "org.jetbrains.kotlin:kotlin-stdlib-common" + "org.jetbrains.kotlin:kotlin-stdlib-common", + "org.jetbrains.kotlin:kotlin-stdlib-jdk8" + ], + "org.jetbrains.kotlinx:kotlinx-coroutines-guava": [ + "com.google.guava:guava", + "org.jetbrains.kotlin:kotlin-stdlib-jdk8", + "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm" ], "org.jetbrains.kotlinx:kotlinx-coroutines-test": [ - "org.jetbrains.kotlin:kotlin-stdlib", - "org.jetbrains.kotlinx:kotlinx-coroutines-core", - "org.jetbrains.kotlinx:kotlinx-coroutines-debug" + "org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm" + ], + "org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm": [ + "org.jetbrains.kotlin:kotlin-stdlib-common", + "org.jetbrains.kotlin:kotlin-stdlib-jdk8", + "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm" ], "org.jetbrains.kotlinx:kotlinx-metadata-jvm": [ "org.jetbrains.kotlin:kotlin-stdlib" @@ -2544,10 +2522,6 @@ ] }, "packages": { - "android.arch.core:common": [ - "android.arch.core.internal", - "android.arch.core.util" - ], "androidx.annotation:annotation": [ "androidx.annotation" ], @@ -2603,9 +2577,6 @@ "com.android.databinding:baseLibrary": [ "android.databinding" ], - "com.android.support:support-annotations": [ - "android.support.annotation" - ], "com.android.tools.build.jetifier:jetifier-core": [ "com.android.tools.build.jetifier.core", "com.android.tools.build.jetifier.core.config", @@ -2845,29 +2816,12 @@ "com.squareup.moshi.kotlin.reflect" ], "com.squareup.moshi:moshi-kotlin-codegen": [ - "com.squareup.moshi.kotlin.codegen", "com.squareup.moshi.kotlin.codegen.api", - "com.squareup.moshi.kotlinpoet.classinspector.elements", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.auto.common", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.annotations", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.base", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.cache", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.collect", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.escape", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.eventbus", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.graph", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.hash", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.html", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.io", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.math", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.net", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.primitives", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.reflect", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.util.concurrent", - "com.squareup.moshi.kotlinpoet.classinspector.elements.shaded.com.google.common.xml", + "com.squareup.moshi.kotlin.codegen.apt", + "com.squareup.moshi.kotlin.codegen.ksp", "com.squareup.moshi.kotlinpoet.metadata", + "com.squareup.moshi.kotlinpoet.metadata.classinspectors", "com.squareup.moshi.kotlinpoet.metadata.specs", - "com.squareup.moshi.kotlinpoet.metadata.specs.internal", "com.squareup.moshi.kotlinx.metadata", "com.squareup.moshi.kotlinx.metadata.impl", "com.squareup.moshi.kotlinx.metadata.impl.extensions", @@ -2880,7 +2834,9 @@ "com.squareup.moshi.kotlinx.metadata.internal.metadata.serialization", "com.squareup.moshi.kotlinx.metadata.internal.protobuf", "com.squareup.moshi.kotlinx.metadata.jvm", - "com.squareup.moshi.kotlinx.metadata.jvm.impl" + "com.squareup.moshi.kotlinx.metadata.jvm.impl", + "shadow.com.google.auto.common", + "shadow.com.squareup.kotlinpoet.ksp" ], "com.squareup.okhttp3:mockwebserver": [ "okhttp3.internal.duplex", @@ -2937,7 +2893,8 @@ ], "com.squareup:kotlinpoet": [ "com.squareup.kotlinpoet", - "com.squareup.kotlinpoet.jvm" + "com.squareup.kotlinpoet.jvm", + "com.squareup.kotlinpoet.tags" ], "commons-codec:commons-codec": [ "org.apache.commons.codec", @@ -4208,6 +4165,7 @@ "org.jetbrains.kotlin:kotlin-stdlib-jdk8": [ "kotlin.collections.jdk8", "kotlin.internal.jdk8", + "kotlin.jvm.jdk8", "kotlin.random.jdk8", "kotlin.streams.jdk8", "kotlin.text.jdk8", @@ -4234,52 +4192,12 @@ "kotlinx.coroutines.intrinsics", "kotlinx.coroutines.scheduling", "kotlinx.coroutines.selects", - "kotlinx.coroutines.sync", - "kotlinx.coroutines.test" + "kotlinx.coroutines.sync" ], - "org.jetbrains.kotlinx:kotlinx-coroutines-debug": [ - "kotlinx.coroutines.debug", - "kotlinx.coroutines.debug.internal", - "kotlinx.coroutines.debug.junit4", - "kotlinx.coroutines.repackaged.net.bytebuddy", - "kotlinx.coroutines.repackaged.net.bytebuddy.agent", - "kotlinx.coroutines.repackaged.net.bytebuddy.agent.builder", - "kotlinx.coroutines.repackaged.net.bytebuddy.asm", - "kotlinx.coroutines.repackaged.net.bytebuddy.build", - "kotlinx.coroutines.repackaged.net.bytebuddy.description", - "kotlinx.coroutines.repackaged.net.bytebuddy.description.annotation", - "kotlinx.coroutines.repackaged.net.bytebuddy.description.enumeration", - "kotlinx.coroutines.repackaged.net.bytebuddy.description.field", - "kotlinx.coroutines.repackaged.net.bytebuddy.description.method", - "kotlinx.coroutines.repackaged.net.bytebuddy.description.modifier", - "kotlinx.coroutines.repackaged.net.bytebuddy.description.type", - "kotlinx.coroutines.repackaged.net.bytebuddy.dynamic", - "kotlinx.coroutines.repackaged.net.bytebuddy.dynamic.loading", - "kotlinx.coroutines.repackaged.net.bytebuddy.dynamic.scaffold", - "kotlinx.coroutines.repackaged.net.bytebuddy.dynamic.scaffold.inline", - "kotlinx.coroutines.repackaged.net.bytebuddy.dynamic.scaffold.subclass", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation.attribute", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation.auxiliary", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation.bind", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation.bind.annotation", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation.bytecode", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation.bytecode.assign", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation.bytecode.assign.primitive", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation.bytecode.assign.reference", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation.bytecode.collection", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation.bytecode.constant", - "kotlinx.coroutines.repackaged.net.bytebuddy.implementation.bytecode.member", - "kotlinx.coroutines.repackaged.net.bytebuddy.jar.asm", - "kotlinx.coroutines.repackaged.net.bytebuddy.jar.asm.commons", - "kotlinx.coroutines.repackaged.net.bytebuddy.jar.asm.signature", - "kotlinx.coroutines.repackaged.net.bytebuddy.matcher", - "kotlinx.coroutines.repackaged.net.bytebuddy.pool", - "kotlinx.coroutines.repackaged.net.bytebuddy.utility", - "kotlinx.coroutines.repackaged.net.bytebuddy.utility.privilege", - "kotlinx.coroutines.repackaged.net.bytebuddy.utility.visitor" + "org.jetbrains.kotlinx:kotlinx-coroutines-guava": [ + "kotlinx.coroutines.guava" ], - "org.jetbrains.kotlinx:kotlinx-coroutines-test": [ + "org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm": [ "kotlinx.coroutines.test", "kotlinx.coroutines.test.internal" ], @@ -4496,9 +4414,6 @@ }, "repositories": { "https://maven.google.com/": [ - "android.arch.core:common", - "android.arch.core:core-testing:aar", - "android.arch.core:runtime:aar", "androidx.activity:activity:aar", "androidx.annotation:annotation", "androidx.annotation:annotation-experimental:aar", @@ -4582,7 +4497,6 @@ "androidx.work:work-testing:aar", "com.almworks.sqlite4java:sqlite4java", "com.android.databinding:baseLibrary", - "com.android.support:support-annotations", "com.android.tools.build.jetifier:jetifier-core", "com.android.tools.build:aapt2-proto", "com.android.tools:annotations", @@ -4722,8 +4636,9 @@ "org.jetbrains.kotlinx:kotlinx-coroutines-android", "org.jetbrains.kotlinx:kotlinx-coroutines-core", "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", - "org.jetbrains.kotlinx:kotlinx-coroutines-debug", + "org.jetbrains.kotlinx:kotlinx-coroutines-guava", "org.jetbrains.kotlinx:kotlinx-coroutines-test", + "org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm", "org.jetbrains.kotlinx:kotlinx-metadata-jvm", "org.jetbrains:annotations", "org.mockito.kotlin:mockito-kotlin", @@ -4748,9 +4663,6 @@ "org.snakeyaml:snakeyaml-engine" ], "https://repo1.maven.org/maven2/": [ - "android.arch.core:common", - "android.arch.core:core-testing:aar", - "android.arch.core:runtime:aar", "androidx.activity:activity:aar", "androidx.annotation:annotation", "androidx.annotation:annotation-experimental:aar", @@ -4834,7 +4746,6 @@ "androidx.work:work-testing:aar", "com.almworks.sqlite4java:sqlite4java", "com.android.databinding:baseLibrary", - "com.android.support:support-annotations", "com.android.tools.build.jetifier:jetifier-core", "com.android.tools.build:aapt2-proto", "com.android.tools:annotations", @@ -4974,8 +4885,9 @@ "org.jetbrains.kotlinx:kotlinx-coroutines-android", "org.jetbrains.kotlinx:kotlinx-coroutines-core", "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", - "org.jetbrains.kotlinx:kotlinx-coroutines-debug", + "org.jetbrains.kotlinx:kotlinx-coroutines-guava", "org.jetbrains.kotlinx:kotlinx-coroutines-test", + "org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm", "org.jetbrains.kotlinx:kotlinx-metadata-jvm", "org.jetbrains:annotations", "org.mockito.kotlin:mockito-kotlin", @@ -5000,9 +4912,6 @@ "org.snakeyaml:snakeyaml-engine" ], "https://oss.sonatype.org/content/repositories/snapshots/": [ - "android.arch.core:common", - "android.arch.core:core-testing:aar", - "android.arch.core:runtime:aar", "androidx.activity:activity:aar", "androidx.annotation:annotation", "androidx.annotation:annotation-experimental:aar", @@ -5086,7 +4995,6 @@ "androidx.work:work-testing:aar", "com.almworks.sqlite4java:sqlite4java", "com.android.databinding:baseLibrary", - "com.android.support:support-annotations", "com.android.tools.build.jetifier:jetifier-core", "com.android.tools.build:aapt2-proto", "com.android.tools:annotations", @@ -5226,8 +5134,9 @@ "org.jetbrains.kotlinx:kotlinx-coroutines-android", "org.jetbrains.kotlinx:kotlinx-coroutines-core", "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", - "org.jetbrains.kotlinx:kotlinx-coroutines-debug", + "org.jetbrains.kotlinx:kotlinx-coroutines-guava", "org.jetbrains.kotlinx:kotlinx-coroutines-test", + "org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm", "org.jetbrains.kotlinx:kotlinx-metadata-jvm", "org.jetbrains:annotations", "org.mockito.kotlin:mockito-kotlin", @@ -5252,9 +5161,6 @@ "org.snakeyaml:snakeyaml-engine" ], "https://maven.fabric.io/public/": [ - "android.arch.core:common", - "android.arch.core:core-testing:aar", - "android.arch.core:runtime:aar", "androidx.activity:activity:aar", "androidx.annotation:annotation", "androidx.annotation:annotation-experimental:aar", @@ -5338,7 +5244,6 @@ "androidx.work:work-testing:aar", "com.almworks.sqlite4java:sqlite4java", "com.android.databinding:baseLibrary", - "com.android.support:support-annotations", "com.android.tools.build.jetifier:jetifier-core", "com.android.tools.build:aapt2-proto", "com.android.tools:annotations", @@ -5478,8 +5383,9 @@ "org.jetbrains.kotlinx:kotlinx-coroutines-android", "org.jetbrains.kotlinx:kotlinx-coroutines-core", "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", - "org.jetbrains.kotlinx:kotlinx-coroutines-debug", + "org.jetbrains.kotlinx:kotlinx-coroutines-guava", "org.jetbrains.kotlinx:kotlinx-coroutines-test", + "org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm", "org.jetbrains.kotlinx:kotlinx-metadata-jvm", "org.jetbrains:annotations", "org.mockito.kotlin:mockito-kotlin", diff --git a/third_party/versions.bzl b/third_party/versions.bzl index 021b3bb0618..c1dec75774d 100644 --- a/third_party/versions.bzl +++ b/third_party/versions.bzl @@ -47,7 +47,6 @@ MAVEN_PRODUCTION_DEPENDENCY_VERSIONS = { "androidx.viewpager:viewpager": "1.0.0", "androidx.work:work-runtime": "2.4.0", "androidx.work:work-runtime-ktx": "2.4.0", - "com.android.support:support-annotations": "28.0.0", "com.android.tools.build:aapt2-proto": "7.3.1-8691043", "com.crashlytics.sdk.android:crashlytics": "2.9.8", "com.github.bumptech.glide:compiler": "4.11.0", @@ -68,8 +67,8 @@ MAVEN_PRODUCTION_DEPENDENCY_VERSIONS = { "com.google.guava:failureaccess": "1.0.1", "com.google.j2objc:j2objc-annotations": "1.3", "com.google.protobuf:protobuf-javalite": "3.17.3", - "com.squareup.moshi:moshi-kotlin": "1.11.0", - "com.squareup.moshi:moshi-kotlin-codegen": "1.11.0", + "com.squareup.moshi:moshi-kotlin": "1.13.0", + "com.squareup.moshi:moshi-kotlin-codegen": "1.13.0", "com.squareup.okhttp3:okhttp": "4.7.2", "com.squareup.retrofit2:converter-moshi": "2.5.0", "com.squareup.retrofit2:retrofit": "2.9.0", @@ -79,9 +78,10 @@ MAVEN_PRODUCTION_DEPENDENCY_VERSIONS = { "nl.dionsegijn:konfetti": "1.2.5", "org.checkerframework:checker-compat-qual": "2.5.5", "org.checkerframework:checker-qual": "3.21.3", - "org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar": "1.3.72", - "org.jetbrains.kotlinx:kotlinx-coroutines-android": "1.4.1", - "org.jetbrains.kotlinx:kotlinx-coroutines-core": "1.4.3", + "org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar": "1.6.10", + "org.jetbrains.kotlinx:kotlinx-coroutines-android": "1.6.4", + "org.jetbrains.kotlinx:kotlinx-coroutines-core": "1.6.4", + "org.jetbrains.kotlinx:kotlinx-coroutines-guava": "1.6.4", "org.jetbrains:annotations:jar": "13.0", } @@ -89,7 +89,6 @@ MAVEN_PRODUCTION_DEPENDENCY_VERSIONS = { # This list should only contain test-only dependencies. These are dependencies that are guaranteed # cannot be included in production builds of the app. MAVEN_TEST_DEPENDENCY_VERSIONS = { - "android.arch.core:core-testing": "1.1.1", "androidx.arch.core:core-testing": "2.1.0", "androidx.test.espresso:espresso-accessibility": "3.1.0", "androidx.test.espresso:espresso-contrib": "3.1.0", @@ -114,7 +113,7 @@ MAVEN_TEST_DEPENDENCY_VERSIONS = { "org.jetbrains.kotlin:kotlin-compiler-embeddable": "1.5.0", "org.jetbrains.kotlin:kotlin-reflect": "1.3.41", "org.jetbrains.kotlin:kotlin-test-junit": "1.3.72", - "org.jetbrains.kotlinx:kotlinx-coroutines-test": "1.2.2", + "org.jetbrains.kotlinx:kotlinx-coroutines-test": "1.6.4", "org.mockito.kotlin:mockito-kotlin": "3.2.0", "org.mockito:mockito-core": "2.19.0", "org.robolectric:annotations": "4.5", @@ -136,6 +135,10 @@ HTTP_DEPENDENCY_VERSIONS = { "sha": "9425a423a4cb9d9db0356300722d9bd8e634cf539f29d97bb84f457cccd16eb8", "version": "31.0.1", }, + "kotlinx-coroutines-core-jvm": { + "sha": "acc8c74b1fb88121c51221bfa7b6f5e920201bc20183ebf74165dcf5d45a8003", + "version": "1.6.0", + }, "oppia_proto_api": { "version": "9cf993ea0b798a67b3faa21c690c30b9027fb371", }, @@ -156,8 +159,8 @@ HTTP_DEPENDENCY_VERSIONS = { "version": "5.1", }, "rules_kotlin": { - "sha": "58edd86f0f3c5b959c54e656b8e7eb0b0becabd412465c37a2078693c2571f7f", - "version": "v1.5.0-beta-3", + "sha": "12d22a3d9cbcf00f2e2d8f0683ba87d3823cb8c7f6837568dd7e48846e023307", + "version": "v1.5.0", }, "rules_proto": { "sha": "e0cab008a9cdc2400a1d6572167bf9c5afc72e19ee2b862d18581051efab42c9", diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel index e89e9629165..d2fea35d5a5 100644 --- a/tools/BUILD.bazel +++ b/tools/BUILD.bazel @@ -10,7 +10,7 @@ load("@rules_java//java:defs.bzl", "java_plugin") java_plugin( name = "moshi_annotation_processor_plugin", generates_api = True, - processor_class = "com.squareup.moshi.kotlin.codegen.JsonClassCodegenProcessor", + processor_class = "com.squareup.moshi.kotlin.codegen.apt.JsonClassCodegenProcessor", visibility = ["//third_party:__pkg__"], deps = [ "//third_party:com_squareup_moshi_moshi-kotlin", diff --git a/tools/kotlin/BUILD.bazel b/tools/kotlin/BUILD.bazel new file mode 100644 index 00000000000..9348f206bd2 --- /dev/null +++ b/tools/kotlin/BUILD.bazel @@ -0,0 +1,58 @@ +""" +Configurations for a codebase-wide build toolchain for Kotlin. +""" + +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +load("@io_bazel_rules_kotlin//kotlin:core.bzl", "define_kt_toolchain", "kt_javac_options", "kt_kotlinc_options") + +# This exposes a patch file that retroactively adds opt-in support to kt_kotlinc_options (which was +# added in a later version of rules_kotlin that's not available for the version of Bazel used at the +# time of this introduction). +exports_files(["add_kotlinc_optin_support.patch"]) + +string_flag( + name = "warn_mode", + build_setting_default = "failure", + values = [ + "warning", + "failure", + ], +) + +config_setting( + name = "errors_as_warnings", + flag_values = {":warn_mode": "warning"}, +) + +config_setting( + name = "errors_as_failures", + flag_values = {":warn_mode": "failure"}, +) + +kt_kotlinc_options( + name = "oppia_kotlinc_options", + warn = select({ + ":errors_as_failures": "error", + ":errors_as_warnings": "report", + }), + x_optin = ["kotlin.RequiresOptIn"], + x_use_experimental = False, +) + +# TODO(#4936): Fix "warnings as errors" for processor-generated Java code. +kt_javac_options( + name = "oppia_javac_options", + warn = select({ + ":errors_as_failures": "error", + ":errors_as_warnings": "report", + }), +) + +define_kt_toolchain( + name = "kotlin_16_jdk9_toolchain", + api_version = "1.6", + javac_options = ":oppia_javac_options", + jvm_target = "9", + kotlinc_options = ":oppia_kotlinc_options", + language_version = "1.6", +) diff --git a/tools/kotlin/add_kotlinc_optin_support.patch b/tools/kotlin/add_kotlinc_optin_support.patch new file mode 100644 index 00000000000..b0c379b673f --- /dev/null +++ b/tools/kotlin/add_kotlinc_optin_support.patch @@ -0,0 +1,59 @@ +--- src/main/starlark/core/repositories/configured_rules.bzl ++++ src/main/starlark/core/repositories/configured_rules.bzl +@@ -1,6 +1,56 @@ + def _rules_repository_impl(repository_ctx): + attr = repository_ctx.attr + repository_ctx.extract(attr.archive) ++ repository_ctx.file( ++ "provided.patch", ++ content = """ ++--- kotlin/opts.bzl +++++ kotlin/opts.bzl ++@@ -1,3 +1,6 @@ +++def _map_optin_class_to_flag(values): +++ return ["-opt-in=%s" % v for v in values] +++ ++ _KOPTS = { ++ "warn": struct( ++ args = dict( ++@@ -121,6 +124,16 @@ ++ True: ["-Xmulti-platform"], ++ }, ++ ), +++ # Add support for opt-in values per https://github.com/bazelbuild/rules_kotlin/blob/0b75e942e444ccced07cfec50cbc8d925821ed57/src/rkt_1_6/starlark/kotlin/opts.bzl#L196-L204. +++ "x_optin": struct( +++ args = dict( +++ default = [], +++ doc = "Define APIs to opt-in to.", +++ ), +++ type = attr.string_list, +++ value_to_flag = None, +++ map_value_to_flag = _map_optin_class_to_flag, +++ ), ++ } ++ ++ KotlincOptions = provider( ++@@ -158,10 +171,14 @@ ++ if not kotlinc_options: ++ return "" ++ +++ # Updated to support new map_value_to_flag per https://github.com/bazelbuild/rules_kotlin/blob/0b75e942e444ccced07cfec50cbc8d925821ed57/src/main/starlark/core/options/convert.bzl#L3. ++ flags = [] ++ for n, o in _KOPTS.items(): ++ value = getattr(kotlinc_options, n, None) ++- flag = o.value_to_flag.get(value, None) +++ if o.value_to_flag: +++ flag = o.value_to_flag.get(value, None) +++ else: +++ flag = o.map_value_to_flag(value) ++ if flag: ++ flags.extend(flag) ++ return flags ++ ++ """, ++ executable = False ++ ) ++ repository_ctx.patch("provided.patch") + + rules_repository = repository_rule( + implementation = _rules_repository_impl, diff --git a/utility/build.gradle b/utility/build.gradle index be880396432..cc39995dbd0 100644 --- a/utility/build.gradle +++ b/utility/build.gradle @@ -83,9 +83,9 @@ dependencies { 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03', 'androidx.work:work-runtime-ktx:2.4.0', 'com.github.oppia:androidsvg:5bc9c7553e94c3476e8ea32baea3c77567228fcd', - 'com.github.oppia:kotlitex:43139c140833c7120f351d63d74b42c253d2b213', + 'com.github.oppia:kotlitex:ccdf4170817fa3b48b8e1e452772dd58ecb71cf2', 'com.github.bumptech.glide:glide:4.11.0', - 'com.google.dagger:dagger:2.24', + 'com.google.dagger:dagger:2.41', 'com.google.firebase:firebase-analytics-ktx:17.5.0', 'com.google.firebase:firebase-core:17.5.0', 'com.google.firebase:firebase-crashlytics:17.0.0', @@ -93,7 +93,7 @@ dependencies { 'com.google.firebase:firebase-auth-ktx:19.3.1', 'com.google.protobuf:protobuf-javalite:3.17.3', "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version", - 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1', + 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4', ) compileOnly( 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.2', @@ -103,12 +103,12 @@ dependencies { testImplementation( 'androidx.test.ext:junit:1.1.1', 'androidx.test.ext:truth:1.4.0', - 'com.google.dagger:dagger:2.24', + 'com.google.dagger:dagger:2.41', 'com.google.truth:truth:1.1.3', 'com.google.truth.extensions:truth-liteproto-extension:1.1.3', 'junit:junit:4.12', "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version", - 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.2.2', + 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4', 'org.mockito:mockito-core:2.19.0', 'org.robolectric:robolectric:4.5', project(":data"), @@ -116,10 +116,10 @@ dependencies { ) kapt( 'com.github.bumptech.glide:compiler:4.11.0', - 'com.google.dagger:dagger-compiler:2.24' + 'com.google.dagger:dagger-compiler:2.41' ) kaptTest( - 'com.google.dagger:dagger-compiler:2.24' + 'com.google.dagger:dagger-compiler:2.41' ) // TODO(#59): Remove this once Bazel is introduced // sufficiently visible for generated Dagger code. This can be done more cleanly via Bazel since dependencies can be diff --git a/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt b/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt index f8bff8b2b06..ed9efe0d76c 100644 --- a/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/locale/DisplayLocaleImpl.kt @@ -78,7 +78,8 @@ class DisplayLocaleImpl( override fun String.formatInLocaleWithoutWrapping(vararg args: CharSequence): String = format(formattingLocale, *args) - override fun String.capitalizeForHumans(): String = capitalize(formattingLocale) + override fun String.capitalizeForHumans(): String = + replaceFirstChar { if (it.isLowerCase()) it.titlecase(formattingLocale) else it.toString() } override fun Resources.getStringInLocale(@StringRes id: Int): String = getString(id) diff --git a/utility/src/main/java/org/oppia/android/util/locale/MachineLocaleImpl.kt b/utility/src/main/java/org/oppia/android/util/locale/MachineLocaleImpl.kt index 1617a9a72da..b3f47f88170 100644 --- a/utility/src/main/java/org/oppia/android/util/locale/MachineLocaleImpl.kt +++ b/utility/src/main/java/org/oppia/android/util/locale/MachineLocaleImpl.kt @@ -34,13 +34,15 @@ class MachineLocaleImpl @Inject constructor( override fun String.formatForMachines(vararg args: Any?): String = format(machineAndroidLocale, *args) - override fun String.toMachineLowerCase(): String = toLowerCase(machineAndroidLocale) + override fun String.toMachineLowerCase(): String = lowercase(machineAndroidLocale) - override fun String.toMachineUpperCase(): String = toUpperCase(machineAndroidLocale) + override fun String.toMachineUpperCase(): String = uppercase(machineAndroidLocale) - override fun String.capitalizeForMachines(): String = capitalize(machineAndroidLocale) + override fun String.capitalizeForMachines(): String = + replaceFirstChar { if (it.isLowerCase()) it.titlecase(machineAndroidLocale) else it.toString() } - override fun String.decapitalizeForMachines(): String = decapitalize(machineAndroidLocale) + override fun String.decapitalizeForMachines(): String = + replaceFirstChar { it.lowercase(machineAndroidLocale) } override fun String.endsWithIgnoreCase(suffix: String): Boolean = toMachineLowerCase().endsWith(suffix.toMachineLowerCase()) diff --git a/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt b/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt index 7cb8ef98c35..8cab8e1778d 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/EventBundleCreatorTest.kt @@ -85,7 +85,6 @@ import org.oppia.android.app.model.WrittenTranslationLanguageSelection import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.util.platformparameter.EnableLoggingLearnerStudyIds @@ -275,17 +274,15 @@ class EventBundleCreatorTest { } @Test - @RunParameterized( - Iteration("lang_unspecified", "inLang=LANGUAGE_UNSPECIFIED", "expLang=unspecified_language"), - Iteration("ar", "inLang=ARABIC", "expLang=Arabic"), - Iteration("en", "inLang=ENGLISH", "expLang=English"), - Iteration("hi", "inLang=HINDI", "expLang=Hindi"), - Iteration("hi_en", "inLang=HINGLISH", "expLang=Hinglish"), - Iteration("pt", "inLang=PORTUGUESE", "expLang=Portuguese"), - Iteration("pt_br", "inLang=BRAZILIAN_PORTUGUESE", "expLang=Brazilian Portuguese"), - Iteration("sw", "inLang=SWAHILI", "expLang=Swahili"), - Iteration("pcm", "inLang=NIGERIAN_PIDGIN", "expLang=Nigerian Pidgin") - ) + @Iteration("lang_unspecified", "inLang=LANGUAGE_UNSPECIFIED", "expLang=unspecified_language") + @Iteration("ar", "inLang=ARABIC", "expLang=Arabic") + @Iteration("en", "inLang=ENGLISH", "expLang=English") + @Iteration("hi", "inLang=HINDI", "expLang=Hindi") + @Iteration("hi_en", "inLang=HINGLISH", "expLang=Hinglish") + @Iteration("pt", "inLang=PORTUGUESE", "expLang=Portuguese") + @Iteration("pt_br", "inLang=BRAZILIAN_PORTUGUESE", "expLang=Brazilian Portuguese") + @Iteration("sw", "inLang=SWAHILI", "expLang=Swahili") + @Iteration("pcm", "inLang=NIGERIAN_PIDGIN", "expLang=Nigerian Pidgin") fun testFillEventBundle_eventWithSelectedAppLanguage_savesCorrectAppLanguageInBundle() { setUpTestApplicationComponent() val bundle = Bundle() @@ -316,17 +313,15 @@ class EventBundleCreatorTest { } @Test - @RunParameterized( - Iteration("lang_unspecified", "inLang=LANGUAGE_UNSPECIFIED", "expLang=unspecified_language"), - Iteration("ar", "inLang=ARABIC", "expLang=Arabic"), - Iteration("en", "inLang=ENGLISH", "expLang=English"), - Iteration("hi", "inLang=HINDI", "expLang=Hindi"), - Iteration("hi_en", "inLang=HINGLISH", "expLang=Hinglish"), - Iteration("pt", "inLang=PORTUGUESE", "expLang=Portuguese"), - Iteration("pt_br", "inLang=BRAZILIAN_PORTUGUESE", "expLang=Brazilian Portuguese"), - Iteration("sw", "inLang=SWAHILI", "expLang=Swahili"), - Iteration("pcm", "inLang=NIGERIAN_PIDGIN", "expLang=Nigerian Pidgin") - ) + @Iteration("lang_unspecified", "inLang=LANGUAGE_UNSPECIFIED", "expLang=unspecified_language") + @Iteration("ar", "inLang=ARABIC", "expLang=Arabic") + @Iteration("en", "inLang=ENGLISH", "expLang=English") + @Iteration("hi", "inLang=HINDI", "expLang=Hindi") + @Iteration("hi_en", "inLang=HINGLISH", "expLang=Hinglish") + @Iteration("pt", "inLang=PORTUGUESE", "expLang=Portuguese") + @Iteration("pt_br", "inLang=BRAZILIAN_PORTUGUESE", "expLang=Brazilian Portuguese") + @Iteration("sw", "inLang=SWAHILI", "expLang=Swahili") + @Iteration("pcm", "inLang=NIGERIAN_PIDGIN", "expLang=Nigerian Pidgin") fun testFillEventBundle_eventWithSelectedWrittenTranslationsLanguage_savesCorrectWrittenLang() { setUpTestApplicationComponent() val bundle = Bundle() @@ -355,17 +350,15 @@ class EventBundleCreatorTest { } @Test - @RunParameterized( - Iteration("lang_unspecified", "inLang=LANGUAGE_UNSPECIFIED", "expLang=unspecified_language"), - Iteration("ar", "inLang=ARABIC", "expLang=Arabic"), - Iteration("en", "inLang=ENGLISH", "expLang=English"), - Iteration("hi", "inLang=HINDI", "expLang=Hindi"), - Iteration("hi_en", "inLang=HINGLISH", "expLang=Hinglish"), - Iteration("pt", "inLang=PORTUGUESE", "expLang=Portuguese"), - Iteration("pt_br", "inLang=BRAZILIAN_PORTUGUESE", "expLang=Brazilian Portuguese"), - Iteration("sw", "inLang=SWAHILI", "expLang=Swahili"), - Iteration("pcm", "inLang=NIGERIAN_PIDGIN", "expLang=Nigerian Pidgin") - ) + @Iteration("lang_unspecified", "inLang=LANGUAGE_UNSPECIFIED", "expLang=unspecified_language") + @Iteration("ar", "inLang=ARABIC", "expLang=Arabic") + @Iteration("en", "inLang=ENGLISH", "expLang=English") + @Iteration("hi", "inLang=HINDI", "expLang=Hindi") + @Iteration("hi_en", "inLang=HINGLISH", "expLang=Hinglish") + @Iteration("pt", "inLang=PORTUGUESE", "expLang=Portuguese") + @Iteration("pt_br", "inLang=BRAZILIAN_PORTUGUESE", "expLang=Brazilian Portuguese") + @Iteration("sw", "inLang=SWAHILI", "expLang=Swahili") + @Iteration("pcm", "inLang=NIGERIAN_PIDGIN", "expLang=Nigerian Pidgin") fun testFillEventBundle_eventWithSelectedAudioTranslationsLanguage_savesCorrectAudioLang() { setUpTestApplicationComponent() val bundle = Bundle() @@ -1887,145 +1880,143 @@ class EventBundleCreatorTest { } @Test - @RunParameterized( - Iteration("home", "name=HOME_ACTIVITY", "expNameStr=home_activity"), - Iteration("splash", "name=SPLASH_ACTIVITY", "expNameStr=splash_activity"), - Iteration( - "profileChooser", - "name=PROFILE_CHOOSER_ACTIVITY", - "expNameStr=profile_chooser_activity" - ), - Iteration("addProfile", "name=ADD_PROFILE_ACTIVITY", "expNameStr=add_profile_activity"), - Iteration("background", "name=BACKGROUND_SCREEN", "expNameStr=background_screen"), - Iteration("appVersion", "name=APP_VERSION_ACTIVITY", "expNameStr=app_version_activity"), - Iteration( - "administratorControls", - "name=ADMINISTRATOR_CONTROLS_ACTIVITY", - "expNameStr=administrator_controls_activity" - ), - Iteration( - "profileAndDeviceId", - "name=PROFILE_AND_DEVICE_ID_ACTIVITY", - "expNameStr=profile_and_device_id_activity" - ), - Iteration( - "completedStoryList", - "name=COMPLETED_STORY_LIST_ACTIVITY", - "expNameStr=completed_story_list_activity" - ), - Iteration("faqSingle", "name=FAQ_SINGLE_ACTIVITY", "expNameStr=faq_single_activity"), - Iteration("faqList", "name=FAQ_LIST_ACTIVITY", "expNameStr=faq_list_activity"), - Iteration("licenseList", "name=LICENSE_LIST_ACTIVITY", "expNameStr=license_list_activity"), - Iteration( - "licenseTextViewer", - "name=LICENSE_TEXT_VIEWER_ACTIVITY", - "expNameStr=license_text_viewer_activity" - ), - Iteration( - "thirdPartyDependencyList", - "name=THIRD_PARTY_DEPENDENCY_LIST_ACTIVITY", - "expNameStr=third_party_dependency_list_activity" - ), - Iteration("help", "name=HELP_ACTIVITY", "expNameStr=help_activity"), - Iteration( - "recentlyPlayed", - "name=RECENTLY_PLAYED_ACTIVITY", - "expNameStr=recently_played_activity" - ), - Iteration("myDownloads", "name=MY_DOWNLOADS_ACTIVITY", "expNameStr=my_downloads_activity"), - Iteration("onboarding", "name=ONBOARDING_ACTIVITY", "expNameStr=onboarding_activity"), - Iteration( - "ongoingTopicList", - "name=ONGOING_TOPIC_LIST_ACTIVITY", - "expNameStr=ongoing_topic_list_activity" - ), - Iteration( - "audioLanguage", - "name=AUDIO_LANGUAGE_ACTIVITY", - "expNameStr=audio_language_activity" - ), - Iteration("appLanguage", "name=APP_LANGUAGE_ACTIVITY", "expNameStr=app_language_activity"), - Iteration("options", "name=OPTIONS_ACTIVITY", "expNameStr=options_activity"), - Iteration( - "readingTextSize", - "name=READING_TEXT_SIZE_ACTIVITY", - "expNameStr=reading_text_size_activity" - ), - Iteration("exploration", "name=EXPLORATION_ACTIVITY", "expNameStr=exploration_activity"), - Iteration("adminAuth", "name=ADMIN_AUTH_ACTIVITY", "expNameStr=admin_auth_activity"), - Iteration("pinPassword", "name=PIN_PASSWORD_ACTIVITY", "expNameStr=pin_password_activity"), - Iteration( - "profilePicture", - "name=PROFILE_PICTURE_ACTIVITY", - "expNameStr=profile_picture_activity" - ), - Iteration( - "profileProgress", - "name=PROFILE_PROGRESS_ACTIVITY", - "expNameStr=profile_progress_activity" - ), - Iteration("resumeLesson", "name=RESUME_LESSON_ACTIVITY", "expNameStr=resume_lesson_activity"), - Iteration("profileEdit", "name=PROFILE_EDIT_ACTIVITY", "expNameStr=profile_edit_activity"), - Iteration( - "profileResetPin", - "name=PROFILE_RESET_PIN_ACTIVITY", - "expNameStr=profile_reset_pin_activity" - ), - Iteration( - "profileRename", - "name=PROFILE_RENAME_ACTIVITY", - "expNameStr=profile_rename_activity" - ), - Iteration("profileList", "name=PROFILE_LIST_ACTIVITY", "expNameStr=profile_list_activity"), - Iteration("story", "name=STORY_ACTIVITY", "expNameStr=story_activity"), - Iteration("topic", "name=TOPIC_ACTIVITY", "expNameStr=topic_activity"), - Iteration("revisionCard", "name=REVISION_CARD_ACTIVITY", "expNameStr=revision_card_activity"), - Iteration( - "questionPlayer", - "name=QUESTION_PLAYER_ACTIVITY", - "expNameStr=question_player_activity" - ), - Iteration("walkthrough", "name=WALKTHROUGH_ACTIVITY", "expNameStr=walkthrough_activity"), - Iteration( - "developerOptions", - "name=DEVELOPER_OPTIONS_ACTIVITY", - "expNameStr=developer_options_activity" - ), - Iteration( - "viewEventLogs", - "name=VIEW_EVENT_LOGS_ACTIVITY", - "expNameStr=view_event_logs_activity" - ), - Iteration( - "markTopicsCompleted", - "name=MARK_TOPICS_COMPLETED_ACTIVITY", - "expNameStr=mark_topics_completed_activity" - ), - Iteration( - "mathExpressionParser", - "name=MATH_EXPRESSION_PARSER_ACTIVITY", - "expNameStr=math_expression_parser_activity" - ), - Iteration( - "markChaptersCompleted", - "name=MARK_CHAPTERS_COMPLETED_ACTIVITY", - "expNameStr=mark_chapters_completed_activity" - ), - Iteration( - "markStoriesCompleted", - "name=MARK_STORIES_COMPLETED_ACTIVITY", - "expNameStr=mark_stories_completed_activity" - ), - Iteration( - "forceNetworkType", - "name=FORCE_NETWORK_TYPE_ACTIVITY", - "expNameStr=force_network_type_activity" - ), - Iteration("adminPin", "name=ADMIN_PIN_ACTIVITY", "expNameStr=admin_pin_activity"), - Iteration("policies", "name=POLICIES_ACTIVITY", "expNameStr=policies_activity"), - Iteration("unspecified", "name=SCREEN_NAME_UNSPECIFIED", "expNameStr=screen_name_unspecified"), - Iteration("foreground", "name=FOREGROUND_SCREEN", "expNameStr=foreground_screen"), + @Iteration("home", "name=HOME_ACTIVITY", "expNameStr=home_activity") + @Iteration("splash", "name=SPLASH_ACTIVITY", "expNameStr=splash_activity") + @Iteration( + "profileChooser", + "name=PROFILE_CHOOSER_ACTIVITY", + "expNameStr=profile_chooser_activity" + ) + @Iteration("addProfile", "name=ADD_PROFILE_ACTIVITY", "expNameStr=add_profile_activity") + @Iteration("background", "name=BACKGROUND_SCREEN", "expNameStr=background_screen") + @Iteration("appVersion", "name=APP_VERSION_ACTIVITY", "expNameStr=app_version_activity") + @Iteration( + "administratorControls", + "name=ADMINISTRATOR_CONTROLS_ACTIVITY", + "expNameStr=administrator_controls_activity" + ) + @Iteration( + "profileAndDeviceId", + "name=PROFILE_AND_DEVICE_ID_ACTIVITY", + "expNameStr=profile_and_device_id_activity" + ) + @Iteration( + "completedStoryList", + "name=COMPLETED_STORY_LIST_ACTIVITY", + "expNameStr=completed_story_list_activity" + ) + @Iteration("faqSingle", "name=FAQ_SINGLE_ACTIVITY", "expNameStr=faq_single_activity") + @Iteration("faqList", "name=FAQ_LIST_ACTIVITY", "expNameStr=faq_list_activity") + @Iteration("licenseList", "name=LICENSE_LIST_ACTIVITY", "expNameStr=license_list_activity") + @Iteration( + "licenseTextViewer", + "name=LICENSE_TEXT_VIEWER_ACTIVITY", + "expNameStr=license_text_viewer_activity" + ) + @Iteration( + "thirdPartyDependencyList", + "name=THIRD_PARTY_DEPENDENCY_LIST_ACTIVITY", + "expNameStr=third_party_dependency_list_activity" + ) + @Iteration("help", "name=HELP_ACTIVITY", "expNameStr=help_activity") + @Iteration( + "recentlyPlayed", + "name=RECENTLY_PLAYED_ACTIVITY", + "expNameStr=recently_played_activity" + ) + @Iteration("myDownloads", "name=MY_DOWNLOADS_ACTIVITY", "expNameStr=my_downloads_activity") + @Iteration("onboarding", "name=ONBOARDING_ACTIVITY", "expNameStr=onboarding_activity") + @Iteration( + "ongoingTopicList", + "name=ONGOING_TOPIC_LIST_ACTIVITY", + "expNameStr=ongoing_topic_list_activity" + ) + @Iteration( + "audioLanguage", + "name=AUDIO_LANGUAGE_ACTIVITY", + "expNameStr=audio_language_activity" + ) + @Iteration("appLanguage", "name=APP_LANGUAGE_ACTIVITY", "expNameStr=app_language_activity") + @Iteration("options", "name=OPTIONS_ACTIVITY", "expNameStr=options_activity") + @Iteration( + "readingTextSize", + "name=READING_TEXT_SIZE_ACTIVITY", + "expNameStr=reading_text_size_activity" + ) + @Iteration("exploration", "name=EXPLORATION_ACTIVITY", "expNameStr=exploration_activity") + @Iteration("adminAuth", "name=ADMIN_AUTH_ACTIVITY", "expNameStr=admin_auth_activity") + @Iteration("pinPassword", "name=PIN_PASSWORD_ACTIVITY", "expNameStr=pin_password_activity") + @Iteration( + "profilePicture", + "name=PROFILE_PICTURE_ACTIVITY", + "expNameStr=profile_picture_activity" + ) + @Iteration( + "profileProgress", + "name=PROFILE_PROGRESS_ACTIVITY", + "expNameStr=profile_progress_activity" + ) + @Iteration("resumeLesson", "name=RESUME_LESSON_ACTIVITY", "expNameStr=resume_lesson_activity") + @Iteration("profileEdit", "name=PROFILE_EDIT_ACTIVITY", "expNameStr=profile_edit_activity") + @Iteration( + "profileResetPin", + "name=PROFILE_RESET_PIN_ACTIVITY", + "expNameStr=profile_reset_pin_activity" + ) + @Iteration( + "profileRename", + "name=PROFILE_RENAME_ACTIVITY", + "expNameStr=profile_rename_activity" + ) + @Iteration("profileList", "name=PROFILE_LIST_ACTIVITY", "expNameStr=profile_list_activity") + @Iteration("story", "name=STORY_ACTIVITY", "expNameStr=story_activity") + @Iteration("topic", "name=TOPIC_ACTIVITY", "expNameStr=topic_activity") + @Iteration("revisionCard", "name=REVISION_CARD_ACTIVITY", "expNameStr=revision_card_activity") + @Iteration( + "questionPlayer", + "name=QUESTION_PLAYER_ACTIVITY", + "expNameStr=question_player_activity" + ) + @Iteration("walkthrough", "name=WALKTHROUGH_ACTIVITY", "expNameStr=walkthrough_activity") + @Iteration( + "developerOptions", + "name=DEVELOPER_OPTIONS_ACTIVITY", + "expNameStr=developer_options_activity" + ) + @Iteration( + "viewEventLogs", + "name=VIEW_EVENT_LOGS_ACTIVITY", + "expNameStr=view_event_logs_activity" + ) + @Iteration( + "markTopicsCompleted", + "name=MARK_TOPICS_COMPLETED_ACTIVITY", + "expNameStr=mark_topics_completed_activity" + ) + @Iteration( + "mathExpressionParser", + "name=MATH_EXPRESSION_PARSER_ACTIVITY", + "expNameStr=math_expression_parser_activity" + ) + @Iteration( + "markChaptersCompleted", + "name=MARK_CHAPTERS_COMPLETED_ACTIVITY", + "expNameStr=mark_chapters_completed_activity" + ) + @Iteration( + "markStoriesCompleted", + "name=MARK_STORIES_COMPLETED_ACTIVITY", + "expNameStr=mark_stories_completed_activity" + ) + @Iteration( + "forceNetworkType", + "name=FORCE_NETWORK_TYPE_ACTIVITY", + "expNameStr=force_network_type_activity" ) + @Iteration("adminPin", "name=ADMIN_PIN_ACTIVITY", "expNameStr=admin_pin_activity") + @Iteration("policies", "name=POLICIES_ACTIVITY", "expNameStr=policies_activity") + @Iteration("unspecified", "name=SCREEN_NAME_UNSPECIFIED", "expNameStr=screen_name_unspecified") + @Iteration("foreground", "name=FOREGROUND_SCREEN", "expNameStr=foreground_screen") fun testMetricsBundle_addScreenName_verifyConversionToCorrectAnalyticalName() { setUpTestApplicationComponent() val bundle = Bundle() diff --git a/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorImplTest.kt b/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorImplTest.kt index fade559675a..161a3b19fa7 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/performancemetrics/PerformanceMetricsAssessorImplTest.kt @@ -21,7 +21,6 @@ import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.platformparameter.TestPlatformParameterModule @@ -220,47 +219,45 @@ class PerformanceMetricsAssessorImplTest { } @Test - @RunParameterized( - Iteration( - "zeroDoubleValue", - "firstCpuValue=1000", - "secondCpuValue=1000", - "firstAppTimeValue=1665790650", - "secondAppTimeValue=1665790700", - "firstNumberOfOnlineCoresValue=6", - "secondNumberOfOnlineCoresValue=2", - "relativeCpuUsage=0.00" - ), - Iteration( - "nonZeroDoubleValueTillTwoDecimalPoints", - "firstCpuValue=1000", - "secondCpuValue=1100", - "firstAppTimeValue=1665790650", - "secondAppTimeValue=1665790700", - "firstNumberOfOnlineCoresValue=6", - "secondNumberOfOnlineCoresValue=2", - "relativeCpuUsage=0.50" - ), - Iteration( - "nonZeroDoubleValueTillSevenDecimalPoints", - "firstCpuValue=1000", - "secondCpuValue=12100", - "firstAppTimeValue=1665790650", - "secondAppTimeValue=1869790700", - "firstNumberOfOnlineCoresValue=6", - "secondNumberOfOnlineCoresValue=8", - "relativeCpuUsage=0.0000077" - ), - Iteration( - "nonZeroDoubleValueTillElevenDecimalPoints", - "firstCpuValue=1000", - "secondCpuValue=2100", - "firstAppTimeValue=1665790650", - "secondAppTimeValue=186933790700", - "firstNumberOfOnlineCoresValue=6", - "secondNumberOfOnlineCoresValue=3", - "relativeCpuUsage=0.00000000239" - ) + @Iteration( + "zeroDoubleValue", + "firstCpuValue=1000", + "secondCpuValue=1000", + "firstAppTimeValue=1665790650", + "secondAppTimeValue=1665790700", + "firstNumberOfOnlineCoresValue=6", + "secondNumberOfOnlineCoresValue=2", + "relativeCpuUsage=0.00" + ) + @Iteration( + "nonZeroDoubleValueTillTwoDecimalPoints", + "firstCpuValue=1000", + "secondCpuValue=1100", + "firstAppTimeValue=1665790650", + "secondAppTimeValue=1665790700", + "firstNumberOfOnlineCoresValue=6", + "secondNumberOfOnlineCoresValue=2", + "relativeCpuUsage=0.50" + ) + @Iteration( + "nonZeroDoubleValueTillSevenDecimalPoints", + "firstCpuValue=1000", + "secondCpuValue=12100", + "firstAppTimeValue=1665790650", + "secondAppTimeValue=1869790700", + "firstNumberOfOnlineCoresValue=6", + "secondNumberOfOnlineCoresValue=8", + "relativeCpuUsage=0.0000077" + ) + @Iteration( + "nonZeroDoubleValueTillElevenDecimalPoints", + "firstCpuValue=1000", + "secondCpuValue=2100", + "firstAppTimeValue=1665790650", + "secondAppTimeValue=186933790700", + "firstNumberOfOnlineCoresValue=6", + "secondNumberOfOnlineCoresValue=3", + "relativeCpuUsage=0.00000000239" ) fun testAssessor_setFirstAndSecondSnapshot_returnsCorrectRelativeCpuUsage() { val firstSnapshot = PerformanceMetricsAssessor.CpuSnapshot( @@ -279,17 +276,15 @@ class PerformanceMetricsAssessorImplTest { } @Test - @RunParameterized( - Iteration( - "zeroDeltaOnlineCores", - "firstNumberOfOnlineCoresValue=6", - "secondNumberOfOnlineCoresValue=0" - ), - Iteration( - "negativeOnlineCores", - "firstNumberOfOnlineCoresValue=-1", - "secondNumberOfOnlineCoresValue=6" - ) + @Iteration( + "zeroDeltaOnlineCores", + "firstNumberOfOnlineCoresValue=6", + "secondNumberOfOnlineCoresValue=0" + ) + @Iteration( + "negativeOnlineCores", + "firstNumberOfOnlineCoresValue=-1", + "secondNumberOfOnlineCoresValue=6" ) fun testAssessor_inputInvalidOnlineCoresValues_calculateCpuUsage_returnsNull() { val firstSnapshot = PerformanceMetricsAssessor.CpuSnapshot( @@ -310,11 +305,9 @@ class PerformanceMetricsAssessorImplTest { } @Test - @RunParameterized( - Iteration("negativeDeltaCpuValue", "firstCpuValue=1000", "secondCpuValue=900"), - Iteration("negativeCpuValue", "firstCpuValue=1000", "secondCpuValue=-900"), - Iteration("outOfBoundsCpuValue", "firstCpuValue=1000", "secondCpuValue=9223372036854775807"), - ) + @Iteration("negativeDeltaCpuValue", "firstCpuValue=1000", "secondCpuValue=900") + @Iteration("negativeCpuValue", "firstCpuValue=1000", "secondCpuValue=-900") + @Iteration("outOfBoundsCpuValue", "firstCpuValue=1000", "secondCpuValue=9223372036854775807") fun testAssessor_inputInvalidCpuTimeValues_calculateCpuUsage_returnsNull() { val firstSnapshot = PerformanceMetricsAssessor.CpuSnapshot( firstAppTimeValue, @@ -334,22 +327,20 @@ class PerformanceMetricsAssessorImplTest { } @Test - @RunParameterized( - Iteration( - "negativeDeltaAppTimeValue", - "firstAppTimeValue=1665790650", - "secondAppTimeValue=1665790050" - ), - Iteration( - "negativeAppTimeValue", - "firstAppTimeValue=1665790650", - "secondAppTimeValue=-1665790050" - ), - Iteration( - "zeroDeltaAppTimeValue", - "firstAppTimeValue=1665790650", - "secondAppTimeValue=1665790650" - ), + @Iteration( + "negativeDeltaAppTimeValue", + "firstAppTimeValue=1665790650", + "secondAppTimeValue=1665790050" + ) + @Iteration( + "negativeAppTimeValue", + "firstAppTimeValue=1665790650", + "secondAppTimeValue=-1665790050" + ) + @Iteration( + "zeroDeltaAppTimeValue", + "firstAppTimeValue=1665790650", + "secondAppTimeValue=1665790650" ) fun testAssessor_inputInvalidAppTimeValues_calculateCpuUsage_returnsNull() { val firstSnapshot = PerformanceMetricsAssessor.CpuSnapshot( @@ -380,11 +371,9 @@ class PerformanceMetricsAssessorImplTest { } @Test - @RunParameterized( - Iteration("memoryEqualToLowerBound", "totalMemory=0"), - Iteration("memoryInRange", "totalMemory=1147483648"), - Iteration("memoryJustBelowUpperBound", "totalMemory=2147483647") - ) + @Iteration("memoryEqualToLowerBound", "totalMemory=0") + @Iteration("memoryInRange", "totalMemory=1147483648") + @Iteration("memoryJustBelowUpperBound", "totalMemory=2147483647") fun testAssessor_setTotalMemoryForLowMemoryRange_returnsCorrectLowMemoryTier() { val memoryInfo = ActivityManager.MemoryInfo() memoryInfo.totalMem = totalMemory @@ -395,11 +384,9 @@ class PerformanceMetricsAssessorImplTest { } @Test - @RunParameterized( - Iteration("memoryEqualToLowerBound", "totalMemory=2147483649"), - Iteration("memoryInRange", "totalMemory=2684354560"), - Iteration("memoryEqualToUpperBound", "totalMemory=3221225472") - ) + @Iteration("memoryEqualToLowerBound", "totalMemory=2147483649") + @Iteration("memoryInRange", "totalMemory=2684354560") + @Iteration("memoryEqualToUpperBound", "totalMemory=3221225472") fun testAssessor_setTotalMemoryForMediumMemoryRange_retsCorrectMediumMemoryTier() { val memoryInfo = ActivityManager.MemoryInfo() memoryInfo.totalMem = totalMemory @@ -410,13 +397,11 @@ class PerformanceMetricsAssessorImplTest { } @Test - @RunParameterized( - Iteration("memoryEqualToLowerBound", "totalMemory=3221225473"), - Iteration("memoryInRange", "totalMemory=5221225472"), - Iteration( - "memoryEqualToMaxValue", - "totalMemory=9223372036854775807" - ) + @Iteration("memoryEqualToLowerBound", "totalMemory=3221225473") + @Iteration("memoryInRange", "totalMemory=5221225472") + @Iteration( + "memoryEqualToMaxValue", + "totalMemory=9223372036854775807" ) fun testAssessor_setTotalMemoryForHighMemoryRange_retsCorrectHighMemoryTier() { val memoryInfo = ActivityManager.MemoryInfo() diff --git a/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt b/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt index 203ad029c5b..5a20ba0cc07 100644 --- a/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt @@ -10,7 +10,6 @@ import org.oppia.android.app.model.MathExpression import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedJunitTestRunner import org.oppia.android.testing.math.ComparableOperationSubject.Companion.assertThat @@ -1449,12 +1448,10 @@ class ExpressionToComparableOperationConverterTest { */ @Test - @RunParameterized( - Iteration(name = "(1+2)*sqrt(3)", "op1=(1+2)", "op2=sqrt(3)"), - Iteration(name = "sqrt(3)*(1+2)", "op1=sqrt(3)", "op2=(1+2)"), - Iteration(name = "(1+2)*(3^4)", "op1=(1+2)", "op2=(3^4)"), - Iteration(name = "(3^4)*(1+2)", "op1=(3^4)", "op2=(1+2)") - ) + @Iteration(name = "(1+2)*sqrt(3)", "op1=(1+2)", "op2=sqrt(3)") + @Iteration(name = "sqrt(3)*(1+2)", "op1=sqrt(3)", "op2=(1+2)") + @Iteration(name = "(1+2)*(3^4)", "op1=(1+2)", "op2=(3^4)") + @Iteration(name = "(3^4)*(1+2)", "op1=(3^4)", "op2=(1+2)") fun testConvert_additionAndNonCommutativeOp_samePrecedence_returnsOpWithSummationFirst() { val expression = parseNumericExpression("$op1 * $op2") @@ -1475,12 +1472,10 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "2+sqrt(3)", "op1=2", "op2=sqrt(3)"), - Iteration(name = "sqrt(3)+2", "op1=sqrt(3)", "op2=2"), - Iteration(name = "2+3^4", "op1=2", "op2=3^4"), - Iteration(name = "3^4+2", "op1=3^4", "op2=2") - ) + @Iteration(name = "2+sqrt(3)", "op1=2", "op2=sqrt(3)") + @Iteration(name = "sqrt(3)+2", "op1=sqrt(3)", "op2=2") + @Iteration(name = "2+3^4", "op1=2", "op2=3^4") + @Iteration(name = "3^4+2", "op1=3^4", "op2=2") fun testConvert_constantAndNonCommutativeOp_samePrecedence_returnsOpWithNonCommutativeFirst() { val expression = parseNumericExpression("$op1 + $op2") @@ -1501,10 +1496,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "2*x", "op1=2", "op2=x"), - Iteration(name = "x*2", "op1=x", "op2=2") - ) + @Iteration(name = "2*x", "op1=2", "op2=x") + @Iteration(name = "x*2", "op1=x", "op2=2") fun testConvert_constantAndVariable_samePrecedence_returnsOpWithConstantFirst() { val expression = parseAlgebraicExpression("$op1 * $op2") @@ -1525,10 +1518,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "x+(-y)", "op1=x", "op2=(-y)"), - Iteration(name = "(-y)+x", "op1=(-y)", "op2=x") - ) + @Iteration(name = "x+(-y)", "op1=x", "op2=(-y)") + @Iteration(name = "(-y)+x", "op1=(-y)", "op2=x") fun testConvert_positiveAndNegativeVariables_returnsOpWithNegatedLast() { val expression = parseAlgebraicExpression("$op1 + $op2") @@ -1551,10 +1542,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "x*(1/y)", "op1=x", "op2=(1/y)"), - Iteration(name = "(1/y)*x", "op1=(1/y)", "op2=x") - ) + @Iteration(name = "x*(1/y)", "op1=x", "op2=(1/y)") + @Iteration(name = "(1/y)*x", "op1=(1/y)", "op2=x") fun testConvert_invertedAndNonInvertedVariables_returnsOpWithInvertedLast() { val expression = parseAlgebraicExpression("$op1 * $op2") @@ -1581,16 +1570,14 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "(1+2)*(2+3)", "op1=1+2", "op2=2+3"), - Iteration(name = "(2+1)*(2+3)", "op1=2+1", "op2=2+3"), - Iteration(name = "(1+2)*(3+2)", "op1=1+2", "op2=3+2"), - Iteration(name = "(2+1)*(3+2)", "op1=2+1", "op2=3+2"), - Iteration(name = "(2+3)*(1+2)", "op1=2+3", "op2=1+2"), - Iteration(name = "(2+3)*(2+1)", "op1=2+3", "op2=2+1"), - Iteration(name = "(3+2)*(1+2)", "op1=3+2", "op2=1+2"), - Iteration(name = "(3+2)*(2+1)", "op1=3+2", "op2=2+1") - ) + @Iteration(name = "(1+2)*(2+3)", "op1=1+2", "op2=2+3") + @Iteration(name = "(2+1)*(2+3)", "op1=2+1", "op2=2+3") + @Iteration(name = "(1+2)*(3+2)", "op1=1+2", "op2=3+2") + @Iteration(name = "(2+1)*(3+2)", "op1=2+1", "op2=3+2") + @Iteration(name = "(2+3)*(1+2)", "op1=2+3", "op2=1+2") + @Iteration(name = "(2+3)*(2+1)", "op1=2+3", "op2=2+1") + @Iteration(name = "(3+2)*(1+2)", "op1=3+2", "op2=1+2") + @Iteration(name = "(3+2)*(2+1)", "op1=3+2", "op2=2+1") fun testConvert_twoAdditionsInProduct_smallerSumIsFirst() { val expression = parseNumericExpression("($op1)*($op2)") @@ -1626,16 +1613,14 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "(2*3)+(4*5)", "op1=2*3", "op2=4*5"), - Iteration(name = "(3*2)+(4*5)", "op1=3*2", "op2=4*5"), - Iteration(name = "(2*3)+(5*4)", "op1=2*3", "op2=5*4"), - Iteration(name = "(3*2)+(5*4)", "op1=3*2", "op2=5*4"), - Iteration(name = "(4*5)+(2*3)", "op1=4*5", "op2=2*3"), - Iteration(name = "(4*5)+(3*2)", "op1=4*5", "op2=3*2"), - Iteration(name = "(5*4)+(2*3)", "op1=5*4", "op2=2*3"), - Iteration(name = "(5*4)+(3*2)", "op1=5*4", "op2=3*2") - ) + @Iteration(name = "(2*3)+(4*5)", "op1=2*3", "op2=4*5") + @Iteration(name = "(3*2)+(4*5)", "op1=3*2", "op2=4*5") + @Iteration(name = "(2*3)+(5*4)", "op1=2*3", "op2=5*4") + @Iteration(name = "(3*2)+(5*4)", "op1=3*2", "op2=5*4") + @Iteration(name = "(4*5)+(2*3)", "op1=4*5", "op2=2*3") + @Iteration(name = "(4*5)+(3*2)", "op1=4*5", "op2=3*2") + @Iteration(name = "(5*4)+(2*3)", "op1=5*4", "op2=2*3") + @Iteration(name = "(5*4)+(3*2)", "op1=5*4", "op2=3*2") fun testConvert_twoMultiplicationsInSum_smallerProductIsFirst() { val expression = parseNumericExpression("($op1)+($op2)") @@ -1673,10 +1658,8 @@ class ExpressionToComparableOperationConverterTest { /* Non-commutative sorting */ @Test - @RunParameterized( - Iteration(name = "(2^3)+sqrt(2)", "op1=(2^3)", "op2=sqrt(2)"), - Iteration(name = "sqrt(2)+(2^3)", "op1=sqrt(2)", "op2=(2^3)") - ) + @Iteration(name = "(2^3)+sqrt(2)", "op1=(2^3)", "op2=sqrt(2)") + @Iteration(name = "sqrt(2)+(2^3)", "op1=sqrt(2)", "op2=(2^3)") fun testConvert_expAndSqrt_samePrecedence_returnsOpWithExpThenSqrt() { val expression = parseNumericExpression("$op1+$op2") @@ -1701,23 +1684,21 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - // const^const + const^const - Iteration(name = "(2^3)+(4^5)", "op1=2^3", "op2=4^5"), - Iteration(name = "(2^5)+(4^3)", "op1=2^5", "op2=4^3"), - Iteration(name = "(4^3)+(2^5)", "op1=4^3", "op2=2^5"), - Iteration(name = "(4^5)+(2^3)", "op1=4^5", "op2=2^3"), - // const^var + const^var - Iteration(name = "(2^x)+(4^5)", "op1=2^x", "op2=4^5"), - Iteration(name = "(2^5)+(4^x)", "op1=2^5", "op2=4^x"), - Iteration(name = "(4^x)+(2^5)", "op1=4^x", "op2=2^5"), - Iteration(name = "(4^5)+(2^x)", "op1=4^5", "op2=2^x"), - // const^(var or const) + const^(const or var) - Iteration(name = "(2^x)+(4^y)", "op1=2^x", "op2=4^y"), - Iteration(name = "(2^y)+(4^x)", "op1=2^y", "op2=4^x"), - Iteration(name = "(4^x)+(2^y)", "op1=4^x", "op2=2^y"), - Iteration(name = "(4^y)+(2^x)", "op1=4^y", "op2=2^x") - ) + // const^const + const^const + @Iteration(name = "(2^3)+(4^5)", "op1=2^3", "op2=4^5") + @Iteration(name = "(2^5)+(4^3)", "op1=2^5", "op2=4^3") + @Iteration(name = "(4^3)+(2^5)", "op1=4^3", "op2=2^5") + @Iteration(name = "(4^5)+(2^3)", "op1=4^5", "op2=2^3") + // const^var + const^var + @Iteration(name = "(2^x)+(4^5)", "op1=2^x", "op2=4^5") + @Iteration(name = "(2^5)+(4^x)", "op1=2^5", "op2=4^x") + @Iteration(name = "(4^x)+(2^5)", "op1=4^x", "op2=2^5") + @Iteration(name = "(4^5)+(2^x)", "op1=4^5", "op2=2^x") + // const^(var or const) + const^(const or var) + @Iteration(name = "(2^x)+(4^y)", "op1=2^x", "op2=4^y") + @Iteration(name = "(2^y)+(4^x)", "op1=2^y", "op2=4^x") + @Iteration(name = "(4^x)+(2^y)", "op1=4^x", "op2=2^y") + @Iteration(name = "(4^y)+(2^x)", "op1=4^y", "op2=2^x") fun testConvert_addTwoExps_lhs1Const_rhs1Any_lhs2Const_rhs2Any_returnsOpWithLhsSizeBasedOrder() { // Note that optional errors need to be disabled as part of testing exponents as powers. val expression = @@ -1756,23 +1737,21 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - // var^const + var^const - Iteration(name = "(u^3)+(v^5)", "op1=u^3", "op2=v^5"), - Iteration(name = "(u^5)+(v^3)", "op1=u^5", "op2=v^3"), - Iteration(name = "(v^3)+(u^5)", "op1=v^3", "op2=u^5"), - Iteration(name = "(v^5)+(u^3)", "op1=v^5", "op2=u^3"), - // var^var + var^var - Iteration(name = "(u^x)+(v^5)", "op1=u^x", "op2=v^5"), - Iteration(name = "(u^5)+(v^x)", "op1=u^5", "op2=v^x"), - Iteration(name = "(v^x)+(u^5)", "op1=v^x", "op2=u^5"), - Iteration(name = "(v^5)+(u^x)", "op1=v^5", "op2=u^x"), - // var^(var or const) + var^(const or var) - Iteration(name = "(u^x)+(v^y)", "op1=u^x", "op2=v^y"), - Iteration(name = "(u^y)+(v^x)", "op1=u^y", "op2=v^x"), - Iteration(name = "(v^x)+(u^y)", "op1=v^x", "op2=u^y"), - Iteration(name = "(v^y)+(u^x)", "op1=v^y", "op2=u^x") - ) + // var^const + var^const + @Iteration(name = "(u^3)+(v^5)", "op1=u^3", "op2=v^5") + @Iteration(name = "(u^5)+(v^3)", "op1=u^5", "op2=v^3") + @Iteration(name = "(v^3)+(u^5)", "op1=v^3", "op2=u^5") + @Iteration(name = "(v^5)+(u^3)", "op1=v^5", "op2=u^3") + // var^var + var^var + @Iteration(name = "(u^x)+(v^5)", "op1=u^x", "op2=v^5") + @Iteration(name = "(u^5)+(v^x)", "op1=u^5", "op2=v^x") + @Iteration(name = "(v^x)+(u^5)", "op1=v^x", "op2=u^5") + @Iteration(name = "(v^5)+(u^x)", "op1=v^5", "op2=u^x") + // var^(var or const) + var^(const or var) + @Iteration(name = "(u^x)+(v^y)", "op1=u^x", "op2=v^y") + @Iteration(name = "(u^y)+(v^x)", "op1=u^y", "op2=v^x") + @Iteration(name = "(v^x)+(u^y)", "op1=v^x", "op2=u^y") + @Iteration(name = "(v^y)+(u^x)", "op1=v^y", "op2=u^x") fun testConvert_addTwoExps_lhs1Var_rhs1Any_lhs2Var_rhs2Any_returnsOpWithLhsLetterBasedOrder() { // Note that optional errors need to be disabled as part of testing exponents as powers. val expression = @@ -1816,10 +1795,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "sqrt(2)+sqrt(3)", "op1=2", "op2=3"), - Iteration(name = "sqrt(3)+sqrt(2)", "op1=3", "op2=2") - ) + @Iteration(name = "sqrt(2)+sqrt(3)", "op1=2", "op2=3") + @Iteration(name = "sqrt(3)+sqrt(2)", "op1=3", "op2=2") fun testConvert_addTwoSqrts_leftConst_rightConst_returnsOpWithSqrtsByArgSize() { val expression = parseNumericExpression("sqrt($op1)+sqrt($op2)") @@ -1852,10 +1829,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "sqrt(x)+sqrt(y)", "op1=x", "op2=y"), - Iteration(name = "sqrt(y)+sqrt(x)", "op1=y", "op2=x") - ) + @Iteration(name = "sqrt(x)+sqrt(y)", "op1=x", "op2=y") + @Iteration(name = "sqrt(y)+sqrt(x)", "op1=y", "op2=x") fun testConvert_addTwoSqrts_leftVar_rightVar_returnsOpWithSqrtsByVariableOrder() { val expression = parseAlgebraicExpression("sqrt($op1)+sqrt($op2)") @@ -1888,10 +1863,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "sqrt(2)+sqrt(x)", "op1=2", "op2=x"), - Iteration(name = "sqrt(x)+sqrt(2)", "op1=x", "op2=2") - ) + @Iteration(name = "sqrt(2)+sqrt(x)", "op1=2", "op2=x") + @Iteration(name = "sqrt(x)+sqrt(2)", "op1=x", "op2=2") fun testConvert_addTwoSqrts_oneConst_oneVar_returnsOpWithSqrtsByConstFirst() { val expression = parseAlgebraicExpression("sqrt($op1)+sqrt($op2)") @@ -1926,10 +1899,8 @@ class ExpressionToComparableOperationConverterTest { /* Constant & variable sorting */ @Test - @RunParameterized( - Iteration(name = "2+3", "op1=2", "op2=3"), - Iteration(name = "3+2", "op1=3", "op2=2") - ) + @Iteration(name = "2+3", "op1=2", "op2=3") + @Iteration(name = "3+2", "op1=3", "op2=2") fun testConvert_addTwoConstants_leftInteger_rightInteger_returnsOpSortedByValues() { val expression = parseNumericExpression("$op1 + $op2") @@ -1954,10 +1925,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "3.2+6.3", "op1=3.2", "op2=6.3"), - Iteration(name = "6.3+3.2", "op1=6.3", "op2=3.2") - ) + @Iteration(name = "3.2+6.3", "op1=3.2", "op2=6.3") + @Iteration(name = "6.3+3.2", "op1=6.3", "op2=3.2") fun testConvert_addTwoConstants_leftDouble_rightDouble_returnsOpSortedByValues() { val expression = parseNumericExpression("$op1 + $op2") @@ -1982,10 +1951,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "3+6.3", "op1=3", "op2=6.3"), - Iteration(name = "6.3+3", "op1=6.3", "op2=3") - ) + @Iteration(name = "3+6.3", "op1=3", "op2=6.3") + @Iteration(name = "6.3+3", "op1=6.3", "op2=3") fun testConvert_addTwoConstants_smallInt_largeDouble_returnsOpWithIntFirst() { val expression = parseNumericExpression("$op1 + $op2") @@ -2010,10 +1977,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "8+6.3", "op1=8", "op2=6.3"), - Iteration(name = "6.3+8", "op1=6.3", "op2=8") - ) + @Iteration(name = "8+6.3", "op1=8", "op2=6.3") + @Iteration(name = "6.3+8", "op1=6.3", "op2=8") fun testConvert_addTwoConstants_largeInt_smallDouble_returnsOpWithDoubleFirst() { val expression = parseNumericExpression("$op1 + $op2") @@ -2038,10 +2003,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "x+6", "op1=x", "op2=6"), - Iteration(name = "6+x", "op1=6", "op2=x") - ) + @Iteration(name = "x+6", "op1=x", "op2=6") + @Iteration(name = "6+x", "op1=6", "op2=x") fun testConvert_addVarAndIntConstant_returnsOpWithConstantFirst() { val expression = parseAlgebraicExpression("$op1 + $op2") @@ -2066,10 +2029,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "3.6+x", "op1=3.6", "op2=x"), - Iteration(name = "x+3.6", "op1=x", "op2=3.6") - ) + @Iteration(name = "3.6+x", "op1=3.6", "op2=x") + @Iteration(name = "x+3.6", "op1=x", "op2=3.6") fun testConvert_addVarAndDoubleConstant_returnsOpWithConstantFirst() { val expression = parseAlgebraicExpression("$op1 + $op2") @@ -2117,10 +2078,8 @@ class ExpressionToComparableOperationConverterTest { } @Test - @RunParameterized( - Iteration(name = "x+y", "op1=x", "op2=y"), - Iteration(name = "y+x", "op1=y", "op2=x") - ) + @Iteration(name = "x+y", "op1=x", "op2=y") + @Iteration(name = "y+x", "op1=y", "op2=x") fun testConvert_addTwoVariables_oneX_oneY_returnsOpWithXThenY() { val expression = parseAlgebraicExpression("$op1 + $op2") diff --git a/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt index 6406f3e6e70..371048728af 100644 --- a/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt @@ -8,7 +8,6 @@ import org.oppia.android.app.model.MathExpression import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedJunitTestRunner import org.oppia.android.testing.math.PolynomialSubject.Companion.assertThat @@ -172,17 +171,15 @@ class MathExpressionExtensionsTest { } @Test - @RunParameterized( - Iteration("2==2", "exp1=2", "exp2=2"), - Iteration("2==2.000000000000001", "exp1=2", "exp2=2.000000000000001"), - Iteration("x+1==x+1", "exp1=x+1", "exp2=x+1"), - Iteration("x-1==x-1", "exp1=x-1", "exp2=x-1"), - Iteration("x*2==x*2", "exp1=x*2", "exp2=x*2"), - Iteration("x/2==x/2", "exp1=x/2", "exp2=x/2"), - Iteration("x^2==x^2", "exp1=x^2", "exp2=x^2"), - Iteration("-x==-x", "exp1=-x", "exp2=-x"), - Iteration("sqrt(x)==sqrt(x)", "exp1=sqrt(x)", "exp2=sqrt(x)") - ) + @Iteration("2==2", "exp1=2", "exp2=2") + @Iteration("2==2.000000000000001", "exp1=2", "exp2=2.000000000000001") + @Iteration("x+1==x+1", "exp1=x+1", "exp2=x+1") + @Iteration("x-1==x-1", "exp1=x-1", "exp2=x-1") + @Iteration("x*2==x*2", "exp1=x*2", "exp2=x*2") + @Iteration("x/2==x/2", "exp1=x/2", "exp2=x/2") + @Iteration("x^2==x^2", "exp1=x^2", "exp2=x^2") + @Iteration("-x==-x", "exp1=-x", "exp2=-x") + @Iteration("sqrt(x)==sqrt(x)", "exp1=sqrt(x)", "exp2=sqrt(x)") fun testIsApproximatelyEqualTo_bothAreSingleTermsOrOperations_andSame_returnsTrue() { val first = parseAlgebraicExpression(exp1) val second = parseAlgebraicExpression(exp2) @@ -195,36 +192,34 @@ class MathExpressionExtensionsTest { } @Test - @RunParameterized( - Iteration("2!=3", "exp1=2", "exp2=3"), - Iteration("2!=3/2", "exp1=2", "exp2=3/2"), - Iteration("2!=3.14", "exp1=2", "exp2=3.14"), - Iteration("x!=y", "exp1=x", "exp2=y"), - Iteration("x!=2", "exp1=x", "exp2=2"), - // The number of terms must match. - Iteration("1+x!=1", "exp1=1+x", "exp2=1"), - Iteration("1+x!=x", "exp1=1+x", "exp2=x"), - Iteration("1+1+x!=2+x", "exp1=1+1+x", "exp2=2+x"), - // Term order must match. - Iteration("1+x!=2+x", "exp1=1+x", "exp2=2+x"), - Iteration("1+x!=x+1", "exp1=1+x", "exp2=x+1"), - Iteration("1-x!=2-x", "exp1=1-x", "exp2=2-x"), - Iteration("1-x!=x-1", "exp1=1-x", "exp2=x-1"), - Iteration("2*x!=3*x", "exp1=2*x", "exp2=3*x"), - Iteration("2*x!=x*2", "exp1=2*x", "exp2=x*2"), - Iteration("x/2!=x/3", "exp1=x/2", "exp2=x/3"), - Iteration("x/2!=2/x", "exp1=x/2", "exp2=2/x"), - Iteration("x^2!=x^3", "exp1=x^2", "exp2=x^3"), - Iteration("x^2!=2^x", "exp1=x^2", "exp2=2^x"), - Iteration("x!=-2", "exp1=x", "exp2=-2"), - Iteration("x!=-x", "exp1=x", "exp2=-x"), - Iteration("sqrt(x)!=sqrt(2)", "exp1=sqrt(x)", "exp2=sqrt(2)"), - // These checks are numerically equivalent but fail due to the expression structure not - // matching. - Iteration("2==2/1", "exp1=2", "exp2=2/1"), - Iteration("1/3==0.33333333", "exp1=1/3", "exp2=0.33333333"), - Iteration("1.5==3/2", "exp1=1.5", "exp2=3/2") - ) + @Iteration("2!=3", "exp1=2", "exp2=3") + @Iteration("2!=3/2", "exp1=2", "exp2=3/2") + @Iteration("2!=3.14", "exp1=2", "exp2=3.14") + @Iteration("x!=y", "exp1=x", "exp2=y") + @Iteration("x!=2", "exp1=x", "exp2=2") + // The number of terms must match. + @Iteration("1+x!=1", "exp1=1+x", "exp2=1") + @Iteration("1+x!=x", "exp1=1+x", "exp2=x") + @Iteration("1+1+x!=2+x", "exp1=1+1+x", "exp2=2+x") + // Term order must match. + @Iteration("1+x!=2+x", "exp1=1+x", "exp2=2+x") + @Iteration("1+x!=x+1", "exp1=1+x", "exp2=x+1") + @Iteration("1-x!=2-x", "exp1=1-x", "exp2=2-x") + @Iteration("1-x!=x-1", "exp1=1-x", "exp2=x-1") + @Iteration("2*x!=3*x", "exp1=2*x", "exp2=3*x") + @Iteration("2*x!=x*2", "exp1=2*x", "exp2=x*2") + @Iteration("x/2!=x/3", "exp1=x/2", "exp2=x/3") + @Iteration("x/2!=2/x", "exp1=x/2", "exp2=2/x") + @Iteration("x^2!=x^3", "exp1=x^2", "exp2=x^3") + @Iteration("x^2!=2^x", "exp1=x^2", "exp2=2^x") + @Iteration("x!=-2", "exp1=x", "exp2=-2") + @Iteration("x!=-x", "exp1=x", "exp2=-x") + @Iteration("sqrt(x)!=sqrt(2)", "exp1=sqrt(x)", "exp2=sqrt(2)") + // These checks are numerically equivalent but fail due to the expression structure not + // matching. + @Iteration("2==2/1", "exp1=2", "exp2=2/1") + @Iteration("1/3==0.33333333", "exp1=1/3", "exp2=0.33333333") + @Iteration("1.5==3/2", "exp1=1.5", "exp2=3/2") fun testIsApproximatelyEqualTo_bothAreSingleTermsOrOperations_butDifferent_returnsFalse() { // Some expressions may attempt normally disallowed expressions (such as '2^x'). val first = parseAlgebraicExpression(exp1, errorCheckingMode = REQUIRED_ONLY) diff --git a/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt b/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt index 89e14517e5e..3a164f810f1 100644 --- a/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt @@ -13,7 +13,6 @@ import org.oppia.android.app.model.MathExpression import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedJunitTestRunner import org.oppia.android.testing.math.MathParsingErrorSubject.Companion.assertThat @@ -542,35 +541,55 @@ class MathExpressionParserTest { } @Test - @RunParameterized( - // Note that these parameters are intentionally set up to avoid double unary operators (such as - // -- or ++) since those result in different errors due to unary operations being higher - // precedence. In general, unary operators can't appear on the right since they'll be treated as - // such. - Iteration("**", "lhsOp=*", "rhsOp=*"), Iteration("×*", "lhsOp=×", "rhsOp=*"), - Iteration("/*", "lhsOp=/", "rhsOp=*"), Iteration("÷*", "lhsOp=÷", "rhsOp=*"), - Iteration("^*", "lhsOp=^", "rhsOp=*"), Iteration("+*", "lhsOp=+", "rhsOp=*"), - Iteration("-*", "lhsOp=-", "rhsOp=*"), Iteration("−*", "lhsOp=−", "rhsOp=*"), - Iteration("–*", "lhsOp=–", "rhsOp=*"), Iteration("*×", "lhsOp=*", "rhsOp=×"), - Iteration("××", "lhsOp=×", "rhsOp=×"), Iteration("/×", "lhsOp=/", "rhsOp=×"), - Iteration("÷×", "lhsOp=÷", "rhsOp=×"), Iteration("^×", "lhsOp=^", "rhsOp=×"), - Iteration("+×", "lhsOp=+", "rhsOp=×"), Iteration("-×", "lhsOp=-", "rhsOp=×"), - Iteration("−×", "lhsOp=−", "rhsOp=×"), Iteration("–×", "lhsOp=–", "rhsOp=×"), - Iteration("*/", "lhsOp=*", "rhsOp=/"), Iteration("×/", "lhsOp=×", "rhsOp=/"), - Iteration("//", "lhsOp=/", "rhsOp=/"), Iteration("÷/", "lhsOp=÷", "rhsOp=/"), - Iteration("^/", "lhsOp=^", "rhsOp=/"), Iteration("+/", "lhsOp=+", "rhsOp=/"), - Iteration("-/", "lhsOp=-", "rhsOp=/"), Iteration("−/", "lhsOp=−", "rhsOp=/"), - Iteration("–/", "lhsOp=–", "rhsOp=/"), Iteration("*÷", "lhsOp=*", "rhsOp=÷"), - Iteration("×÷", "lhsOp=×", "rhsOp=÷"), Iteration("/÷", "lhsOp=/", "rhsOp=÷"), - Iteration("÷÷", "lhsOp=÷", "rhsOp=÷"), Iteration("^÷", "lhsOp=^", "rhsOp=÷"), - Iteration("+÷", "lhsOp=+", "rhsOp=÷"), Iteration("-÷", "lhsOp=-", "rhsOp=÷"), - Iteration("−÷", "lhsOp=−", "rhsOp=÷"), Iteration("–÷", "lhsOp=–", "rhsOp=÷"), - Iteration("*^", "lhsOp=*", "rhsOp=^"), Iteration("×^", "lhsOp=×", "rhsOp=^"), - Iteration("/^", "lhsOp=/", "rhsOp=^"), Iteration("÷^", "lhsOp=÷", "rhsOp=^"), - Iteration("^^", "lhsOp=^", "rhsOp=^"), Iteration("+^", "lhsOp=+", "rhsOp=^"), - Iteration("-^", "lhsOp=-", "rhsOp=^"), Iteration("−^", "lhsOp=−", "rhsOp=^"), - Iteration("–^", "lhsOp=–", "rhsOp=^") - ) + // Note that these parameters are intentionally set up to avoid double unary operators (such as + // -- or ++) since those result in different errors due to unary operations being higher + // precedence. In general, unary operators can't appear on the right since they'll be treated as + // such. + @Iteration("**", "lhsOp=*", "rhsOp=*") + @Iteration("×*", "lhsOp=×", "rhsOp=*") + @Iteration("/*", "lhsOp=/", "rhsOp=*") + @Iteration("÷*", "lhsOp=÷", "rhsOp=*") + @Iteration("^*", "lhsOp=^", "rhsOp=*") + @Iteration("+*", "lhsOp=+", "rhsOp=*") + @Iteration("-*", "lhsOp=-", "rhsOp=*") + @Iteration("−*", "lhsOp=−", "rhsOp=*") + @Iteration("–*", "lhsOp=–", "rhsOp=*") + @Iteration("*×", "lhsOp=*", "rhsOp=×") + @Iteration("××", "lhsOp=×", "rhsOp=×") + @Iteration("/×", "lhsOp=/", "rhsOp=×") + @Iteration("÷×", "lhsOp=÷", "rhsOp=×") + @Iteration("^×", "lhsOp=^", "rhsOp=×") + @Iteration("+×", "lhsOp=+", "rhsOp=×") + @Iteration("-×", "lhsOp=-", "rhsOp=×") + @Iteration("−×", "lhsOp=−", "rhsOp=×") + @Iteration("–×", "lhsOp=–", "rhsOp=×") + @Iteration("*/", "lhsOp=*", "rhsOp=/") + @Iteration("×/", "lhsOp=×", "rhsOp=/") + @Iteration("//", "lhsOp=/", "rhsOp=/") + @Iteration("÷/", "lhsOp=÷", "rhsOp=/") + @Iteration("^/", "lhsOp=^", "rhsOp=/") + @Iteration("+/", "lhsOp=+", "rhsOp=/") + @Iteration("-/", "lhsOp=-", "rhsOp=/") + @Iteration("−/", "lhsOp=−", "rhsOp=/") + @Iteration("–/", "lhsOp=–", "rhsOp=/") + @Iteration("*÷", "lhsOp=*", "rhsOp=÷") + @Iteration("×÷", "lhsOp=×", "rhsOp=÷") + @Iteration("/÷", "lhsOp=/", "rhsOp=÷") + @Iteration("÷÷", "lhsOp=÷", "rhsOp=÷") + @Iteration("^÷", "lhsOp=^", "rhsOp=÷") + @Iteration("+÷", "lhsOp=+", "rhsOp=÷") + @Iteration("-÷", "lhsOp=-", "rhsOp=÷") + @Iteration("−÷", "lhsOp=−", "rhsOp=÷") + @Iteration("–÷", "lhsOp=–", "rhsOp=÷") + @Iteration("*^", "lhsOp=*", "rhsOp=^") + @Iteration("×^", "lhsOp=×", "rhsOp=^") + @Iteration("/^", "lhsOp=/", "rhsOp=^") + @Iteration("÷^", "lhsOp=÷", "rhsOp=^") + @Iteration("^^", "lhsOp=^", "rhsOp=^") + @Iteration("+^", "lhsOp=+", "rhsOp=^") + @Iteration("-^", "lhsOp=-", "rhsOp=^") + @Iteration("−^", "lhsOp=−", "rhsOp=^") + @Iteration("–^", "lhsOp=–", "rhsOp=^") fun testParseNumExp_adjacentBinaryOps_returnsSubsequentBinaryOperatorsErrorWithDetails() { val expression = "1 $lhsOp$rhsOp 2" @@ -632,15 +651,13 @@ class MathExpressionParserTest { } @Test - @RunParameterized( - // Note that unary operators like '+' and '-' are excluded here since they may result in valid - // unary operations. - Iteration("nothing_times_something_asterisk", "binOp=*"), - Iteration("nothing_times_something", "binOp=×"), - Iteration("nothing_divides_something_slash", "binOp=/"), - Iteration("nothing_divides_something", "binOp=÷"), - Iteration("nothing_to_power_of_something", "binOp=^") - ) + // Note that unary operators like '+' and '-' are excluded here since they may result in valid + // unary operations. + @Iteration("nothing_times_something_asterisk", "binOp=*") + @Iteration("nothing_times_something", "binOp=×") + @Iteration("nothing_divides_something_slash", "binOp=/") + @Iteration("nothing_divides_something", "binOp=÷") + @Iteration("nothing_to_power_of_something", "binOp=^") fun testParseNumExp_binOnlyOps_noLeftValue_returnsNoVarOrNumBeforeBinOperatorErrorWithDetails() { val expression = "$binOp 2" val operator = BINARY_SYMBOL_TO_OPERATOR_MAP.getValue(binOp) @@ -673,15 +690,13 @@ class MathExpressionParserTest { } @Test - @RunParameterized( - // Note that unary operators like '+' and '-' are excluded here since they may result in valid - // unary operations. - Iteration("nothing_times_something_asterisk", "binOp=*"), - Iteration("nothing_times_something", "binOp=×"), - Iteration("nothing_divides_something_slash", "binOp=/"), - Iteration("nothing_divides_something", "binOp=÷"), - Iteration("nothing_to_power_of_something", "binOp=^") - ) + // Note that unary operators like '+' and '-' are excluded here since they may result in valid + // unary operations. + @Iteration("nothing_times_something_asterisk", "binOp=*") + @Iteration("nothing_times_something", "binOp=×") + @Iteration("nothing_divides_something_slash", "binOp=/") + @Iteration("nothing_divides_something", "binOp=÷") + @Iteration("nothing_to_power_of_something", "binOp=^") fun testParseAlgExp_binOnlyOps_noLeftValue_returnsNoVarOrNumBeforeBinOperatorErrorWithDetails() { val expression = "$binOp x" val operator = BINARY_SYMBOL_TO_OPERATOR_MAP.getValue(binOp) @@ -696,17 +711,15 @@ class MathExpressionParserTest { } @Test - @RunParameterized( - Iteration("something_times_nothing_asterisk", "binOp=*"), - Iteration("something_times_nothing", "binOp=×"), - Iteration("something_divides_nothing_slash", "binOp=/"), - Iteration("something_divides_nothing", "binOp=÷"), - Iteration("something_to_power_of_nothing", "binOp=^"), - Iteration("something_adds_nothing", "binOp=+"), - Iteration("something_subtracts_nothing_hyphen", "binOp=-"), - Iteration("something_subtracts_nothing_en_dash", "binOp=–"), - Iteration("something_subtracts_nothing", "binOp=−") - ) + @Iteration("something_times_nothing_asterisk", "binOp=*") + @Iteration("something_times_nothing", "binOp=×") + @Iteration("something_divides_nothing_slash", "binOp=/") + @Iteration("something_divides_nothing", "binOp=÷") + @Iteration("something_to_power_of_nothing", "binOp=^") + @Iteration("something_adds_nothing", "binOp=+") + @Iteration("something_subtracts_nothing_hyphen", "binOp=-") + @Iteration("something_subtracts_nothing_en_dash", "binOp=–") + @Iteration("something_subtracts_nothing", "binOp=−") fun testParseNumExp_binaryOps_noRightValue_returnsNoVarOrNumAfterBinOperatorErrorWithDetails() { val expression = "2 $binOp" val operator = BINARY_SYMBOL_TO_OPERATOR_MAP.getValue(binOp) @@ -721,17 +734,15 @@ class MathExpressionParserTest { } @Test - @RunParameterized( - Iteration("something_times_nothing_asterisk", "binOp=*"), - Iteration("something_times_nothing", "binOp=×"), - Iteration("something_divides_nothing_slash", "binOp=/"), - Iteration("something_divides_nothing", "binOp=÷"), - Iteration("something_to_power_of_nothing", "binOp=^"), - Iteration("something_adds_nothing", "binOp=+"), - Iteration("something_subtracts_nothing_hyphen", "binOp=-"), - Iteration("something_subtracts_nothing_en_dash", "binOp=–"), - Iteration("something_subtracts_nothing", "binOp=−") - ) + @Iteration("something_times_nothing_asterisk", "binOp=*") + @Iteration("something_times_nothing", "binOp=×") + @Iteration("something_divides_nothing_slash", "binOp=/") + @Iteration("something_divides_nothing", "binOp=÷") + @Iteration("something_to_power_of_nothing", "binOp=^") + @Iteration("something_adds_nothing", "binOp=+") + @Iteration("something_subtracts_nothing_hyphen", "binOp=-") + @Iteration("something_subtracts_nothing_en_dash", "binOp=–") + @Iteration("something_subtracts_nothing", "binOp=−") fun testParseAlgExp_binaryOps_noRightValue_returnsNoVarOrNumAfterBinOperatorErrorWithDetails() { val expression = "x $binOp" val operator = BINARY_SYMBOL_TO_OPERATOR_MAP.getValue(binOp) @@ -746,13 +757,11 @@ class MathExpressionParserTest { } @Test - @RunParameterized( - Iteration("var_directly_in_exp", "subExp=x"), - Iteration("var_directly_in_sub_exp", "subExp=(1+x)"), - Iteration("var_directly_in_nested_exp", "subExp=3^x"), - Iteration("var_directly_in_sqrt", "subExp=sqrt(x)"), - Iteration("var_in_unary", "subExp=-x") - ) + @Iteration("var_directly_in_exp", "subExp=x") + @Iteration("var_directly_in_sub_exp", "subExp=(1+x)") + @Iteration("var_directly_in_nested_exp", "subExp=3^x") + @Iteration("var_directly_in_sqrt", "subExp=sqrt(x)") + @Iteration("var_in_unary", "subExp=-x") fun testParseAlgExp_powersWithVariableExpressions_returnsExponentIsVariableExpressionError() { val expression = "2^$subExp" @@ -965,13 +974,20 @@ class MathExpressionParserTest { } @Test - @RunParameterized( - Iteration("exp", "func=exp"), Iteration("log", "func=log"), Iteration("log10", "func=log10"), - Iteration("ln", "func=ln"), Iteration("sin", "func=sin"), Iteration("cos", "func=cos"), - Iteration("tan", "func=tan"), Iteration("cot", "func=cot"), Iteration("csc", "func=csc"), - Iteration("sec", "func=sec"), Iteration("atan", "func=atan"), Iteration("asin", "func=asin"), - Iteration("acos", "func=acos"), Iteration("abs", "func=abs") - ) + @Iteration("exp", "func=exp") + @Iteration("log", "func=log") + @Iteration("log10", "func=log10") + @Iteration("ln", "func=ln") + @Iteration("sin", "func=sin") + @Iteration("cos", "func=cos") + @Iteration("tan", "func=tan") + @Iteration("cot", "func=cot") + @Iteration("csc", "func=csc") + @Iteration("sec", "func=sec") + @Iteration("atan", "func=atan") + @Iteration("asin", "func=asin") + @Iteration("acos", "func=acos") + @Iteration("abs", "func=abs") fun testParseNumExp_prohibitedFunctionInUse_returnsInvalidFunctionInUseErrorWithDetails() { val expression = "$func(0.5+1)" @@ -993,15 +1009,23 @@ class MathExpressionParserTest { } @Test - @RunParameterized( - Iteration("ex", "func=ex"), Iteration("lo", "func=lo"), Iteration("log1", "func=log1"), - Iteration("si", "func=si"), Iteration("co", "func=co"), Iteration("ta", "func=ta"), - Iteration("cs", "func=cs"), Iteration("se", "func=se"), Iteration("at", "func=at"), - Iteration("ata", "func=ata"), Iteration("as", "func=as"), Iteration("asi", "func=asi"), - Iteration("ac", "func=ac"), Iteration("aco", "func=aco"), Iteration("ab", "func=ab"), - Iteration("sq", "func=sq"), Iteration("sqr", "func=sqr") - - ) + @Iteration("ex", "func=ex") + @Iteration("lo", "func=lo") + @Iteration("log1", "func=log1") + @Iteration("si", "func=si") + @Iteration("co", "func=co") + @Iteration("ta", "func=ta") + @Iteration("cs", "func=cs") + @Iteration("se", "func=se") + @Iteration("at", "func=at") + @Iteration("ata", "func=ata") + @Iteration("as", "func=as") + @Iteration("asi", "func=asi") + @Iteration("ac", "func=ac") + @Iteration("aco", "func=aco") + @Iteration("ab", "func=ab") + @Iteration("sq", "func=sq") + @Iteration("sqr", "func=sqr") fun testParseAlgExp_startOfKnownFunction_returnsFunctionNameIncompleteError() { val expression = "$func(0.5+1)" val error = expectFailureWhenParsingAlgebraicExpression(expression) @@ -1011,10 +1035,12 @@ class MathExpressionParserTest { } @Test - @RunParameterized( - Iteration("a", "func=a"), Iteration("c", "func=c"), Iteration("e", "func=e"), - Iteration("l", "func=l"), Iteration("s", "func=s"), Iteration("t", "func=t") - ) + @Iteration("a", "func=a") + @Iteration("c", "func=c") + @Iteration("e", "func=e") + @Iteration("l", "func=l") + @Iteration("s", "func=s") + @Iteration("t", "func=t") fun testParseAlgExp_firstLetterOfKnownFunctions_areValidExpressions() { val expression = "$func(0.5+1)" val allowedVariables = LOWERCASE_LATIN_ALPHABET diff --git a/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt b/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt index 4cf512cb261..4a620f29118 100644 --- a/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt @@ -6,7 +6,6 @@ import org.junit.runner.RunWith import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedJunitTestRunner import org.oppia.android.testing.math.TokenSubject.Companion.assertThat @@ -160,34 +159,58 @@ class MathTokenizerTest { } @Test - @RunParameterized( - Iteration("a", "variableName=a"), Iteration("A", "variableName=A"), - Iteration("b", "variableName=b"), Iteration("B", "variableName=B"), - Iteration("c", "variableName=c"), Iteration("C", "variableName=C"), - Iteration("d", "variableName=d"), Iteration("D", "variableName=D"), - Iteration("e", "variableName=e"), Iteration("E", "variableName=E"), - Iteration("f", "variableName=f"), Iteration("F", "variableName=F"), - Iteration("g", "variableName=g"), Iteration("G", "variableName=G"), - Iteration("h", "variableName=h"), Iteration("H", "variableName=H"), - Iteration("i", "variableName=i"), Iteration("I", "variableName=I"), - Iteration("j", "variableName=j"), Iteration("J", "variableName=J"), - Iteration("k", "variableName=k"), Iteration("K", "variableName=K"), - Iteration("l", "variableName=l"), Iteration("L", "variableName=L"), - Iteration("m", "variableName=m"), Iteration("M", "variableName=M"), - Iteration("n", "variableName=n"), Iteration("N", "variableName=N"), - Iteration("o", "variableName=o"), Iteration("O", "variableName=O"), - Iteration("p", "variableName=p"), Iteration("P", "variableName=P"), - Iteration("q", "variableName=q"), Iteration("Q", "variableName=Q"), - Iteration("r", "variableName=r"), Iteration("R", "variableName=R"), - Iteration("s", "variableName=s"), Iteration("S", "variableName=S"), - Iteration("t", "variableName=t"), Iteration("T", "variableName=T"), - Iteration("u", "variableName=u"), Iteration("U", "variableName=U"), - Iteration("v", "variableName=v"), Iteration("V", "variableName=V"), - Iteration("w", "variableName=w"), Iteration("W", "variableName=W"), - Iteration("x", "variableName=x"), Iteration("X", "variableName=X"), - Iteration("y", "variableName=y"), Iteration("Y", "variableName=Y"), - Iteration("z", "variableName=z"), Iteration("Z", "variableName=Z") - ) + @Iteration("a", "variableName=a") + @Iteration("A", "variableName=A") + @Iteration("b", "variableName=b") + @Iteration("B", "variableName=B") + @Iteration("c", "variableName=c") + @Iteration("C", "variableName=C") + @Iteration("d", "variableName=d") + @Iteration("D", "variableName=D") + @Iteration("e", "variableName=e") + @Iteration("E", "variableName=E") + @Iteration("f", "variableName=f") + @Iteration("F", "variableName=F") + @Iteration("g", "variableName=g") + @Iteration("G", "variableName=G") + @Iteration("h", "variableName=h") + @Iteration("H", "variableName=H") + @Iteration("i", "variableName=i") + @Iteration("I", "variableName=I") + @Iteration("j", "variableName=j") + @Iteration("J", "variableName=J") + @Iteration("k", "variableName=k") + @Iteration("K", "variableName=K") + @Iteration("l", "variableName=l") + @Iteration("L", "variableName=L") + @Iteration("m", "variableName=m") + @Iteration("M", "variableName=M") + @Iteration("n", "variableName=n") + @Iteration("N", "variableName=N") + @Iteration("o", "variableName=o") + @Iteration("O", "variableName=O") + @Iteration("p", "variableName=p") + @Iteration("P", "variableName=P") + @Iteration("q", "variableName=q") + @Iteration("Q", "variableName=Q") + @Iteration("r", "variableName=r") + @Iteration("R", "variableName=R") + @Iteration("s", "variableName=s") + @Iteration("S", "variableName=S") + @Iteration("t", "variableName=t") + @Iteration("T", "variableName=T") + @Iteration("u", "variableName=u") + @Iteration("U", "variableName=U") + @Iteration("v", "variableName=v") + @Iteration("V", "variableName=V") + @Iteration("w", "variableName=w") + @Iteration("W", "variableName=W") + @Iteration("x", "variableName=x") + @Iteration("X", "variableName=X") + @Iteration("y", "variableName=y") + @Iteration("Y", "variableName=Y") + @Iteration("z", "variableName=z") + @Iteration("Z", "variableName=Z") fun testTokenize_variable_allLatinAlphabetCharactersAreValidVariables() { val tokens = MathTokenizer.tokenize(variableName).toList() @@ -535,14 +558,24 @@ class MathTokenizerTest { } @Test - @RunParameterized( - Iteration("aa", "funcName=aa"), Iteration("ad", "funcName=ad"), Iteration("al", "funcName=al"), - Iteration("ca", "funcName=ca"), Iteration("ce", "funcName=ce"), Iteration("cr", "funcName=cr"), - Iteration("ea", "funcName=ea"), Iteration("ef", "funcName=ef"), Iteration("er", "funcName=er"), - Iteration("la", "funcName=la"), Iteration("lz", "funcName=lz"), Iteration("le", "funcName=le"), - Iteration("sa", "funcName=sa"), Iteration("sp", "funcName=sp"), Iteration("sz", "funcName=sz"), - Iteration("te", "funcName=te"), Iteration("to", "funcName=to"), Iteration("tr", "funcName=tr") - ) + @Iteration("aa", "funcName=aa") + @Iteration("ad", "funcName=ad") + @Iteration("al", "funcName=al") + @Iteration("ca", "funcName=ca") + @Iteration("ce", "funcName=ce") + @Iteration("cr", "funcName=cr") + @Iteration("ea", "funcName=ea") + @Iteration("ef", "funcName=ef") + @Iteration("er", "funcName=er") + @Iteration("la", "funcName=la") + @Iteration("lz", "funcName=lz") + @Iteration("le", "funcName=le") + @Iteration("sa", "funcName=sa") + @Iteration("sp", "funcName=sp") + @Iteration("sz", "funcName=sz") + @Iteration("te", "funcName=te") + @Iteration("to", "funcName=to") + @Iteration("tr", "funcName=tr") fun testTokenize_twoVarsSharingOnlyFirstWithFunctionNames_shouldParseAsVariables() { val tokens = MathTokenizer.tokenize(funcName).toList() @@ -554,16 +587,22 @@ class MathTokenizerTest { } @Test - @RunParameterized( - Iteration("ab", "funcName=ab"), Iteration("ac", "funcName=ac"), - Iteration("aco", "funcName=aco"), Iteration("as", "funcName=as"), - Iteration("asi", "funcName=asi"), Iteration("at", "funcName=at"), - Iteration("ata", "funcName=ata"), Iteration("co", "funcName=co"), - Iteration("cs", "funcName=cs"), Iteration("ex", "funcName=ex"), - Iteration("lo", "funcName=lo"), Iteration("log1", "funcName=log1"), - Iteration("se", "funcName=se"), Iteration("si", "funcName=si"), - Iteration("sq", "funcName=sq"), Iteration("ta", "funcName=ta") - ) + @Iteration("ab", "funcName=ab") + @Iteration("ac", "funcName=ac") + @Iteration("aco", "funcName=aco") + @Iteration("as", "funcName=as") + @Iteration("asi", "funcName=asi") + @Iteration("at", "funcName=at") + @Iteration("ata", "funcName=ata") + @Iteration("co", "funcName=co") + @Iteration("cs", "funcName=cs") + @Iteration("ex", "funcName=ex") + @Iteration("lo", "funcName=lo") + @Iteration("log1", "funcName=log1") + @Iteration("se", "funcName=se") + @Iteration("si", "funcName=si") + @Iteration("sq", "funcName=sq") + @Iteration("ta", "funcName=ta") fun testTokenize_twoVarsSharedWithFunctionNames_shouldParseAsIncompleteFuncName() { val tokens = MathTokenizer.tokenize(funcName).toList() @@ -616,33 +655,55 @@ class MathTokenizerTest { } @Test - @RunParameterized( - Iteration("α", "token=α"), Iteration("Α", "token=Α"), - Iteration("β", "token=β"), Iteration("Β", "token=Β"), - Iteration("γ", "token=γ"), Iteration("Γ", "token=Γ"), - Iteration("δ", "token=δ"), Iteration("Δ", "token=Δ"), - Iteration("ϵ", "token=ϵ"), Iteration("Ε", "token=Ε"), - Iteration("ζ", "token=ζ"), Iteration("Ζ", "token=Ζ"), - Iteration("η", "token=η"), Iteration("Η", "token=Η"), - Iteration("θ", "token=θ"), Iteration("Θ", "token=Θ"), - Iteration("ι", "token=ι"), Iteration("Ι", "token=Ι"), - Iteration("κ", "token=κ"), Iteration("Κ", "token=Κ"), - Iteration("λ", "token=λ"), Iteration("Λ", "token=Λ"), - Iteration("μ", "token=μ"), Iteration("Μ", "token=Μ"), - Iteration("ν", "token=ν"), Iteration("Ν", "token=Ν"), - Iteration("ξ", "token=ξ"), Iteration("Ξ", "token=Ξ"), - Iteration("ο", "token=ο"), Iteration("Ο", "token=Ο"), - Iteration("π", "token=π"), Iteration("Π", "token=Π"), - Iteration("ρ", "token=ρ"), Iteration("Ρ", "token=Ρ"), - Iteration("σ", "token=σ"), Iteration("Σ", "token=Σ"), - Iteration("τ", "token=τ"), Iteration("Τ", "token=Τ"), - Iteration("υ", "token=υ"), Iteration("Υ", "token=Υ"), - Iteration("ϕ", "token=ϕ"), Iteration("Φ", "token=Φ"), - Iteration("χ", "token=χ"), Iteration("Χ", "token=Χ"), - Iteration("ψ", "token=ψ"), Iteration("Ψ", "token=Ψ"), - Iteration("ω", "token=ω"), Iteration("Ω", "token=Ω"), - Iteration("ς", "token=ς") - ) + @Iteration("α", "token=α") + @Iteration("Α", "token=Α") + @Iteration("β", "token=β") + @Iteration("Β", "token=Β") + @Iteration("γ", "token=γ") + @Iteration("Γ", "token=Γ") + @Iteration("δ", "token=δ") + @Iteration("Δ", "token=Δ") + @Iteration("ϵ", "token=ϵ") + @Iteration("Ε", "token=Ε") + @Iteration("ζ", "token=ζ") + @Iteration("Ζ", "token=Ζ") + @Iteration("η", "token=η") + @Iteration("Η", "token=Η") + @Iteration("θ", "token=θ") + @Iteration("Θ", "token=Θ") + @Iteration("ι", "token=ι") + @Iteration("Ι", "token=Ι") + @Iteration("κ", "token=κ") + @Iteration("Κ", "token=Κ") + @Iteration("λ", "token=λ") + @Iteration("Λ", "token=Λ") + @Iteration("μ", "token=μ") + @Iteration("Μ", "token=Μ") + @Iteration("ν", "token=ν") + @Iteration("Ν", "token=Ν") + @Iteration("ξ", "token=ξ") + @Iteration("Ξ", "token=Ξ") + @Iteration("ο", "token=ο") + @Iteration("Ο", "token=Ο") + @Iteration("π", "token=π") + @Iteration("Π", "token=Π") + @Iteration("ρ", "token=ρ") + @Iteration("Ρ", "token=Ρ") + @Iteration("σ", "token=σ") + @Iteration("Σ", "token=Σ") + @Iteration("τ", "token=τ") + @Iteration("Τ", "token=Τ") + @Iteration("υ", "token=υ") + @Iteration("Υ", "token=Υ") + @Iteration("ϕ", "token=ϕ") + @Iteration("Φ", "token=Φ") + @Iteration("χ", "token=χ") + @Iteration("Χ", "token=Χ") + @Iteration("ψ", "token=ψ") + @Iteration("Ψ", "token=Ψ") + @Iteration("ω", "token=ω") + @Iteration("Ω", "token=Ω") + @Iteration("ς", "token=ς") fun testTokenize_greekLetters_produceInvalidTokens() { val tokens = MathTokenizer.tokenize(token).toList() diff --git a/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt index 9711b1d0c87..1f9824e2b1d 100644 --- a/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt @@ -11,7 +11,6 @@ import org.oppia.android.app.model.Real import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedJunitTestRunner import org.oppia.android.testing.math.PolynomialSubject.Companion.assertThat @@ -1213,14 +1212,12 @@ class PolynomialExtensionsTest { } @Test - @RunParameterized( - Iteration("x+y+z", "var1=x", "var2=y", "var3=z"), - Iteration("x+z+y", "var1=x", "var2=z", "var3=y"), - Iteration("y+x+z", "var1=y", "var2=x", "var3=z"), - Iteration("y+z+x", "var1=y", "var2=z", "var3=x"), - Iteration("z+x+y", "var1=z", "var2=x", "var3=y"), - Iteration("z+y+x", "var1=z", "var2=y", "var3=x") - ) + @Iteration("x+y+z", "var1=x", "var2=y", "var3=z") + @Iteration("x+z+y", "var1=x", "var2=z", "var3=y") + @Iteration("y+x+z", "var1=y", "var2=x", "var3=z") + @Iteration("y+z+x", "var1=y", "var2=z", "var3=x") + @Iteration("z+x+y", "var1=z", "var2=x", "var3=y") + @Iteration("z+y+x", "var1=z", "var2=y", "var3=x") fun testSort_xPlusYPlusZ_inAnyOrder_returnsXPlusYPlusZ() { val polynomial = createPolynomial( createTerm(coefficient = ONE, createVariable(name = var1, power = 1)), diff --git a/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt index bfcb4dba53d..f39b7a75d9a 100644 --- a/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt @@ -9,7 +9,6 @@ import org.oppia.android.testing.assertThrows import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedJunitTestRunner import org.oppia.android.testing.math.RealSubject.Companion.assertThat @@ -329,12 +328,10 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0", "lhsInt=0", "rhsInt=0"), - Iteration("1==1", "lhsInt=1", "rhsInt=1"), - Iteration("2==2", "lhsInt=2", "rhsInt=2"), - Iteration("-2==-2", "lhsInt=-2", "rhsInt=-2") - ) + @Iteration("0==0", "lhsInt=0", "rhsInt=0") + @Iteration("1==1", "lhsInt=1", "rhsInt=1") + @Iteration("2==2", "lhsInt=2", "rhsInt=2") + @Iteration("-2==-2", "lhsInt=-2", "rhsInt=-2") fun testIsApproximatelyEqualTo_oneIsInt_otherIsSameInt_returnsTrue() { val first = createIntegerReal(lhsInt) val second = createIntegerReal(rhsInt) @@ -348,12 +345,10 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0!=1", "lhsInt=0", "rhsInt=1"), - Iteration("0!=2", "lhsInt=0", "rhsInt=2"), - Iteration("-2!=2", "lhsInt=-2", "rhsInt=2"), - Iteration("-2!=-1", "lhsInt=-2", "rhsInt=-1") - ) + @Iteration("0!=1", "lhsInt=0", "rhsInt=1") + @Iteration("0!=2", "lhsInt=0", "rhsInt=2") + @Iteration("-2!=2", "lhsInt=-2", "rhsInt=2") + @Iteration("-2!=-1", "lhsInt=-2", "rhsInt=-1") fun testIsApproximatelyEqualTo_oneIsInt_otherIsDifferentInt_returnsFalse() { val first = createIntegerReal(lhsInt) val second = createIntegerReal(rhsInt) @@ -366,15 +361,13 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0", "lhsInt=0", "rhsFrac=0"), - Iteration("2==2", "lhsInt=2", "rhsFrac=2"), - Iteration("2==2/1", "lhsInt=2", "rhsFrac=2/1"), - Iteration("2==4/2", "lhsInt=2", "rhsFrac=4/2"), - Iteration("-2==-2", "lhsInt=-2", "rhsFrac=-2"), - Iteration("-2==-2/1", "lhsInt=-2", "rhsFrac=-2/1"), - Iteration("-2==-4/2", "lhsInt=-2", "rhsFrac=-4/2") - ) + @Iteration("0==0", "lhsInt=0", "rhsFrac=0") + @Iteration("2==2", "lhsInt=2", "rhsFrac=2") + @Iteration("2==2/1", "lhsInt=2", "rhsFrac=2/1") + @Iteration("2==4/2", "lhsInt=2", "rhsFrac=4/2") + @Iteration("-2==-2", "lhsInt=-2", "rhsFrac=-2") + @Iteration("-2==-2/1", "lhsInt=-2", "rhsFrac=-2/1") + @Iteration("-2==-4/2", "lhsInt=-2", "rhsFrac=-4/2") fun testIsApproximatelyEqualTo_oneIsInt_otherIsSameFraction_returnsTrue() { val first = createIntegerReal(lhsInt) val second = createRationalReal(rhsFrac) @@ -388,12 +381,10 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0!=2", "lhsInt=0", "rhsFrac=2"), - Iteration("2!=4", "lhsInt=2", "rhsFrac=4"), - Iteration("2!=3/2", "lhsInt=2", "rhsFrac=3/2"), - Iteration("2!=-2", "lhsInt=2", "rhsFrac=-2"), - ) + @Iteration("0!=2", "lhsInt=0", "rhsFrac=2") + @Iteration("2!=4", "lhsInt=2", "rhsFrac=4") + @Iteration("2!=3/2", "lhsInt=2", "rhsFrac=3/2") + @Iteration("2!=-2", "lhsInt=2", "rhsFrac=-2") fun testIsApproximatelyEqualTo_oneIsInt_otherIsDifferentFraction_returnsFalse() { val first = createIntegerReal(lhsInt) val second = createRationalReal(rhsFrac) @@ -406,16 +397,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0.0", "lhsInt=0", "rhsDouble=0.0"), - Iteration("1==1.0", "lhsInt=1", "rhsDouble=1.0"), - Iteration("2==2.0", "lhsInt=2", "rhsDouble=2.0"), - Iteration("2==2.000000000000001", "lhsInt=2", "rhsDouble=2.000000000000001"), - Iteration("2==1.999999999999999", "lhsInt=2", "rhsDouble=1.999999999999999"), - Iteration("-2==-2.0", "lhsInt=-2", "rhsDouble=-2.0"), - Iteration("-2==-2.00000000000001", "lhsInt=-2", "rhsDouble=-2.00000000000001"), - Iteration("-2==-1.999999999999999", "lhsInt=-2", "rhsDouble=-1.999999999999999") - ) + @Iteration("0==0.0", "lhsInt=0", "rhsDouble=0.0") + @Iteration("1==1.0", "lhsInt=1", "rhsDouble=1.0") + @Iteration("2==2.0", "lhsInt=2", "rhsDouble=2.0") + @Iteration("2==2.000000000000001", "lhsInt=2", "rhsDouble=2.000000000000001") + @Iteration("2==1.999999999999999", "lhsInt=2", "rhsDouble=1.999999999999999") + @Iteration("-2==-2.0", "lhsInt=-2", "rhsDouble=-2.0") + @Iteration("-2==-2.00000000000001", "lhsInt=-2", "rhsDouble=-2.00000000000001") + @Iteration("-2==-1.999999999999999", "lhsInt=-2", "rhsDouble=-1.999999999999999") fun testIsApproximatelyEqualTo_oneIsInt_otherIsSimilarDouble_returnsTrue() { val first = createIntegerReal(lhsInt) val second = createIrrationalReal(rhsDouble) @@ -429,18 +418,16 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0!=2.0", "lhsInt=0", "rhsDouble=2.0"), - Iteration("2!=0.0", "lhsInt=2", "rhsDouble=0.0"), - Iteration("2!=4.0", "lhsInt=2", "rhsDouble=4.0"), - Iteration("3!=3.14", "lhsInt=3", "rhsDouble=3.14"), - Iteration("2!=2.001", "lhsInt=2", "rhsDouble=2.001"), - Iteration("2!=1.999", "lhsInt=2", "rhsDouble=1.999"), - Iteration("2!=-2.0", "lhsInt=2", "rhsDouble=-2.0"), - Iteration("-2!=2.0", "lhsInt=-2", "rhsDouble=2.0"), - Iteration("-2!=-2.001", "lhsInt=-2", "rhsDouble=-2.001"), - Iteration("-2!=-1.999", "lhsInt=-2", "rhsDouble=-1.999") - ) + @Iteration("0!=2.0", "lhsInt=0", "rhsDouble=2.0") + @Iteration("2!=0.0", "lhsInt=2", "rhsDouble=0.0") + @Iteration("2!=4.0", "lhsInt=2", "rhsDouble=4.0") + @Iteration("3!=3.14", "lhsInt=3", "rhsDouble=3.14") + @Iteration("2!=2.001", "lhsInt=2", "rhsDouble=2.001") + @Iteration("2!=1.999", "lhsInt=2", "rhsDouble=1.999") + @Iteration("2!=-2.0", "lhsInt=2", "rhsDouble=-2.0") + @Iteration("-2!=2.0", "lhsInt=-2", "rhsDouble=2.0") + @Iteration("-2!=-2.001", "lhsInt=-2", "rhsDouble=-2.001") + @Iteration("-2!=-1.999", "lhsInt=-2", "rhsDouble=-1.999") fun testIsApproximatelyEqualTo_oneIsInt_otherIsDifferentDouble_returnsFalse() { val first = createIntegerReal(lhsInt) val second = createIrrationalReal(rhsDouble) @@ -453,16 +440,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0", "lhsFrac=0", "rhsFrac=0"), - Iteration("2==2", "lhsFrac=2", "rhsFrac=2"), - Iteration("2==4/2", "lhsFrac=2", "rhsFrac=4/2"), - Iteration("3/2==1 1/2", "lhsFrac=3/2", "rhsFrac=1 1/2"), - Iteration("-2==-2", "lhsFrac=-2", "rhsFrac=-2"), - Iteration("-2==-4/2", "lhsFrac=-2", "rhsFrac=-4/2"), - Iteration("-3/2==-1 1/2", "lhsFrac=-3/2", "rhsFrac=-1 1/2"), - Iteration("1/3==3/9", "lhsFrac=1/3", "rhsFrac=3/9") - ) + @Iteration("0==0", "lhsFrac=0", "rhsFrac=0") + @Iteration("2==2", "lhsFrac=2", "rhsFrac=2") + @Iteration("2==4/2", "lhsFrac=2", "rhsFrac=4/2") + @Iteration("3/2==1 1/2", "lhsFrac=3/2", "rhsFrac=1 1/2") + @Iteration("-2==-2", "lhsFrac=-2", "rhsFrac=-2") + @Iteration("-2==-4/2", "lhsFrac=-2", "rhsFrac=-4/2") + @Iteration("-3/2==-1 1/2", "lhsFrac=-3/2", "rhsFrac=-1 1/2") + @Iteration("1/3==3/9", "lhsFrac=1/3", "rhsFrac=3/9") fun testIsApproximatelyEqualTo_oneIsFraction_otherIsSameFraction_returnsTrue() { val first = createRationalReal(lhsFrac) val second = createRationalReal(rhsFrac) @@ -476,15 +461,13 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0!=2", "lhsFrac=0", "rhsFrac=2"), - Iteration("3/2!=1/2", "lhsFrac=3/2", "rhsFrac=1/2"), - Iteration("3/2!=1", "lhsFrac=3/2", "rhsFrac=1"), - Iteration("3/2!=-1 1/2", "lhsFrac=3/2", "rhsFrac=-1 1/2"), - Iteration("-3/2!=1 1/2", "lhsFrac=-3/2", "rhsFrac=1 1/2"), - Iteration("-3/2!=-1/2", "lhsFrac=-3/2", "rhsFrac=-1/2"), - Iteration("1/3!=2/3", "lhsFrac=1/3", "rhsFrac=2/3") - ) + @Iteration("0!=2", "lhsFrac=0", "rhsFrac=2") + @Iteration("3/2!=1/2", "lhsFrac=3/2", "rhsFrac=1/2") + @Iteration("3/2!=1", "lhsFrac=3/2", "rhsFrac=1") + @Iteration("3/2!=-1 1/2", "lhsFrac=3/2", "rhsFrac=-1 1/2") + @Iteration("-3/2!=1 1/2", "lhsFrac=-3/2", "rhsFrac=1 1/2") + @Iteration("-3/2!=-1/2", "lhsFrac=-3/2", "rhsFrac=-1/2") + @Iteration("1/3!=2/3", "lhsFrac=1/3", "rhsFrac=2/3") fun testIsApproximatelyEqualTo_oneIsFraction_otherIsDifferentFraction_returnsFalse() { val first = createRationalReal(lhsFrac) val second = createRationalReal(rhsFrac) @@ -497,16 +480,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0.0", "lhsFrac=0", "rhsDouble=0.0"), - Iteration("2==2.0", "lhsFrac=2", "rhsDouble=2.0"), - Iteration("2/1==2.0", "lhsFrac=2/1", "rhsDouble=2.0"), - Iteration("3/2==1.5", "lhsFrac=3/2", "rhsDouble=1.5"), - Iteration("1/3==0.33333333333333333", "lhsFrac=1/3", "rhsDouble=0.33333333333333333"), - Iteration("1 2/3==1.66666666666666666", "lhsFrac=1 2/3", "rhsDouble=1.66666666666666666"), - Iteration("-2==-2.0", "lhsFrac=-2", "rhsDouble=-2.0"), - Iteration("-3/2==-1.5", "lhsFrac=-3/2", "rhsDouble=-1.5") - ) + @Iteration("0==0.0", "lhsFrac=0", "rhsDouble=0.0") + @Iteration("2==2.0", "lhsFrac=2", "rhsDouble=2.0") + @Iteration("2/1==2.0", "lhsFrac=2/1", "rhsDouble=2.0") + @Iteration("3/2==1.5", "lhsFrac=3/2", "rhsDouble=1.5") + @Iteration("1/3==0.33333333333333333", "lhsFrac=1/3", "rhsDouble=0.33333333333333333") + @Iteration("1 2/3==1.66666666666666666", "lhsFrac=1 2/3", "rhsDouble=1.66666666666666666") + @Iteration("-2==-2.0", "lhsFrac=-2", "rhsDouble=-2.0") + @Iteration("-3/2==-1.5", "lhsFrac=-3/2", "rhsDouble=-1.5") fun testIsApproximatelyEqualTo_oneIsFraction_otherIsSimilarDouble_returnsTrue() { val first = createRationalReal(lhsFrac) val second = createIrrationalReal(rhsDouble) @@ -520,19 +501,17 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0!=2.0", "lhsFrac=0", "rhsDouble=2.0"), - Iteration("2!=0.0", "lhsFrac=2", "rhsDouble=0.0"), - Iteration("2/2!=2.0", "lhsFrac=2/2", "rhsDouble=2.0"), - Iteration("1/3!=0.333", "lhsFrac=1/3", "rhsDouble=0.333"), - Iteration("1 2/3!=1.667", "lhsFrac=1 2/3", "rhsDouble=1.667"), - Iteration("22/7!=3.14", "lhsFrac=22/7", "rhsDouble=3.14"), - Iteration("-2!=2.0", "lhsFrac=-2", "rhsDouble=2.0"), - Iteration("2!=-2.0", "lhsFrac=2", "rhsDouble=-2.0"), - Iteration("-2/2!=-2.0", "lhsFrac=-2/2", "rhsDouble=-2.0"), - Iteration("-1/3!=-0.333", "lhsFrac=-1/3", "rhsDouble=-0.333"), - Iteration("-1 2/3!=-1.667", "lhsFrac=-1 2/3", "rhsDouble=-1.667") - ) + @Iteration("0!=2.0", "lhsFrac=0", "rhsDouble=2.0") + @Iteration("2!=0.0", "lhsFrac=2", "rhsDouble=0.0") + @Iteration("2/2!=2.0", "lhsFrac=2/2", "rhsDouble=2.0") + @Iteration("1/3!=0.333", "lhsFrac=1/3", "rhsDouble=0.333") + @Iteration("1 2/3!=1.667", "lhsFrac=1 2/3", "rhsDouble=1.667") + @Iteration("22/7!=3.14", "lhsFrac=22/7", "rhsDouble=3.14") + @Iteration("-2!=2.0", "lhsFrac=-2", "rhsDouble=2.0") + @Iteration("2!=-2.0", "lhsFrac=2", "rhsDouble=-2.0") + @Iteration("-2/2!=-2.0", "lhsFrac=-2/2", "rhsDouble=-2.0") + @Iteration("-1/3!=-0.333", "lhsFrac=-1/3", "rhsDouble=-0.333") + @Iteration("-1 2/3!=-1.667", "lhsFrac=-1 2/3", "rhsDouble=-1.667") fun testIsApproximatelyEqualTo_oneIsFraction_firstIsDifferentDouble_returnsFalse() { val first = createRationalReal(lhsFrac) val second = createIrrationalReal(rhsDouble) @@ -545,23 +524,21 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0.0==0.0", "lhsDouble=0.0", "rhsDouble=0.0"), - Iteration("2.0==2.0", "lhsDouble=2.0", "rhsDouble=2.0"), - Iteration( - "2.000000000000001==1.999999999999999", - "lhsDouble=2.000000000000001", - "rhsDouble=1.999999999999999" - ), - Iteration("3.14==3.14", "lhsDouble=3.14", "rhsDouble=3.14"), - Iteration("-2.0==-2.0", "lhsDouble=-2.0", "rhsDouble=-2.0"), - Iteration( - "-2.000000000000001==-1.999999999999999", - "lhsDouble=-2.000000000000001", - "rhsDouble=-1.999999999999999" - ), - Iteration("-3.14==-3.14", "lhsDouble=-3.14", "rhsDouble=-3.14") + @Iteration("0.0==0.0", "lhsDouble=0.0", "rhsDouble=0.0") + @Iteration("2.0==2.0", "lhsDouble=2.0", "rhsDouble=2.0") + @Iteration( + "2.000000000000001==1.999999999999999", + "lhsDouble=2.000000000000001", + "rhsDouble=1.999999999999999" + ) + @Iteration("3.14==3.14", "lhsDouble=3.14", "rhsDouble=3.14") + @Iteration("-2.0==-2.0", "lhsDouble=-2.0", "rhsDouble=-2.0") + @Iteration( + "-2.000000000000001==-1.999999999999999", + "lhsDouble=-2.000000000000001", + "rhsDouble=-1.999999999999999" ) + @Iteration("-3.14==-3.14", "lhsDouble=-3.14", "rhsDouble=-3.14") fun testIsApproximatelyEqualTo_oneIsDouble_otherIsSimilarDouble_returnsTrue() { val first = createIrrationalReal(lhsDouble) val second = createIrrationalReal(rhsDouble) @@ -575,15 +552,13 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0.0!=2.0", "lhsDouble=0.0", "rhsDouble=2.0"), - Iteration("2.001!=1.999", "lhsDouble=2.001", "rhsDouble=1.999"), - Iteration("2.7!=3.14", "lhsDouble=2.7", "rhsDouble=3.14"), - Iteration("2.7!=-3.14", "lhsDouble=2.7", "rhsDouble=-3.14"), - Iteration("-2.7!=3.14", "lhsDouble=-2.7", "rhsDouble=3.14"), - Iteration("-2.0!=2.0", "lhsDouble=-2.0", "rhsDouble=2.0"), - Iteration("-3.14!=3.14", "lhsDouble=-3.14", "rhsDouble=3.14") - ) + @Iteration("0.0!=2.0", "lhsDouble=0.0", "rhsDouble=2.0") + @Iteration("2.001!=1.999", "lhsDouble=2.001", "rhsDouble=1.999") + @Iteration("2.7!=3.14", "lhsDouble=2.7", "rhsDouble=3.14") + @Iteration("2.7!=-3.14", "lhsDouble=2.7", "rhsDouble=-3.14") + @Iteration("-2.7!=3.14", "lhsDouble=-2.7", "rhsDouble=3.14") + @Iteration("-2.0!=2.0", "lhsDouble=-2.0", "rhsDouble=2.0") + @Iteration("-3.14!=3.14", "lhsDouble=-3.14", "rhsDouble=3.14") fun testIsApproximatelyEqualTo_oneIsDouble_otherIsDifferentDouble_returnsFalse() { val first = createIrrationalReal(lhsDouble) val second = createIrrationalReal(rhsDouble) @@ -1033,15 +1008,13 @@ class RealExtensionsTest { // Addition tests. @Test - @RunParameterized( - Iteration("identity+identity", "lhsInt=0", "rhsInt=0", "expInt=0"), - Iteration("int+identity", "lhsInt=1", "rhsInt=0", "expInt=1"), - Iteration("int+int", "lhsInt=1", "rhsInt=2", "expInt=3"), - Iteration("commutativity", "lhsInt=2", "rhsInt=1", "expInt=3"), - Iteration("int+-int", "lhsInt=1", "rhsInt=-2", "expInt=-1"), - Iteration("-int+int", "lhsInt=-1", "rhsInt=2", "expInt=1"), - Iteration("-int+-int", "lhsInt=-1", "rhsInt=-2", "expInt=-3") - ) + @Iteration("identity+identity", "lhsInt=0", "rhsInt=0", "expInt=0") + @Iteration("int+identity", "lhsInt=1", "rhsInt=0", "expInt=1") + @Iteration("int+int", "lhsInt=1", "rhsInt=2", "expInt=3") + @Iteration("commutativity", "lhsInt=2", "rhsInt=1", "expInt=3") + @Iteration("int+-int", "lhsInt=1", "rhsInt=-2", "expInt=-1") + @Iteration("-int+int", "lhsInt=-1", "rhsInt=2", "expInt=1") + @Iteration("-int+-int", "lhsInt=-1", "rhsInt=-2", "expInt=-3") fun testPlus_intAndInt_returnsInt() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIntegerReal(rhsInt) @@ -1052,16 +1025,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity+identity", "lhsInt=0", "rhsFrac=0/1", "expFrac=0/1"), - Iteration("int+identity", "lhsInt=1", "rhsFrac=0/1", "expFrac=1"), - Iteration("int+fraction", "lhsInt=2", "rhsFrac=1/3", "expFrac=2 1/3"), - Iteration("int+wholeNumberFraction", "lhsInt=2", "rhsFrac=3/1", "expFrac=5"), - Iteration("commutativity", "lhsInt=3", "rhsFrac=2/1", "expFrac=5"), - Iteration("int+-fraction", "lhsInt=2", "rhsFrac=-1/3", "expFrac=1 2/3"), - Iteration("-int+fraction", "lhsInt=-2", "rhsFrac=1/3", "expFrac=-1 2/3"), - Iteration("-int+-fraction", "lhsInt=-2", "rhsFrac=-1/3", "expFrac=-2 1/3") - ) + @Iteration("identity+identity", "lhsInt=0", "rhsFrac=0/1", "expFrac=0/1") + @Iteration("int+identity", "lhsInt=1", "rhsFrac=0/1", "expFrac=1") + @Iteration("int+fraction", "lhsInt=2", "rhsFrac=1/3", "expFrac=2 1/3") + @Iteration("int+wholeNumberFraction", "lhsInt=2", "rhsFrac=3/1", "expFrac=5") + @Iteration("commutativity", "lhsInt=3", "rhsFrac=2/1", "expFrac=5") + @Iteration("int+-fraction", "lhsInt=2", "rhsFrac=-1/3", "expFrac=1 2/3") + @Iteration("-int+fraction", "lhsInt=-2", "rhsFrac=1/3", "expFrac=-1 2/3") + @Iteration("-int+-fraction", "lhsInt=-2", "rhsFrac=-1/3", "expFrac=-2 1/3") fun testPlus_intAndFraction_returnsFraction() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createRationalReal(rhsFrac) @@ -1073,16 +1044,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity+identity", "lhsInt=0", "rhsDouble=0.0", "expDouble=0.0"), - Iteration("int+identity", "lhsInt=1", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("int+double", "lhsInt=1", "rhsDouble=3.14", "expDouble=4.14"), - Iteration("int+wholeNumberDouble", "lhsInt=1", "rhsDouble=3.0", "expDouble=4.0"), - Iteration("commutativity", "lhsInt=3", "rhsDouble=1.0", "expDouble=4.0"), - Iteration("int+-double", "lhsInt=1", "rhsDouble=-3.14", "expDouble=-2.14"), - Iteration("-int+double", "lhsInt=-1", "rhsDouble=3.14", "expDouble=2.14"), - Iteration("-int+-double", "lhsInt=-1", "rhsDouble=-3.14", "expDouble=-4.14") - ) + @Iteration("identity+identity", "lhsInt=0", "rhsDouble=0.0", "expDouble=0.0") + @Iteration("int+identity", "lhsInt=1", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("int+double", "lhsInt=1", "rhsDouble=3.14", "expDouble=4.14") + @Iteration("int+wholeNumberDouble", "lhsInt=1", "rhsDouble=3.0", "expDouble=4.0") + @Iteration("commutativity", "lhsInt=3", "rhsDouble=1.0", "expDouble=4.0") + @Iteration("int+-double", "lhsInt=1", "rhsDouble=-3.14", "expDouble=-2.14") + @Iteration("-int+double", "lhsInt=-1", "rhsDouble=3.14", "expDouble=2.14") + @Iteration("-int+-double", "lhsInt=-1", "rhsDouble=-3.14", "expDouble=-4.14") fun testPlus_intAndDouble_returnsDouble() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIrrationalReal(rhsDouble) @@ -1093,16 +1062,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity+identity", "lhsFrac=0/1", "rhsInt=0", "expFrac=0/1"), - Iteration("fraction+identity", "lhsFrac=1/1", "rhsInt=0", "expFrac=1"), - Iteration("fraction+int", "lhsFrac=1/3", "rhsInt=2", "expFrac=2 1/3"), - Iteration("wholeNumberFraction+int", "lhsFrac=3/1", "rhsInt=2", "expFrac=5"), - Iteration("commutativity", "lhsFrac=2/1", "rhsInt=3", "expFrac=5"), - Iteration("fraction+-int", "lhsFrac=1/3", "rhsInt=-2", "expFrac=-1 2/3"), - Iteration("-fraction+int", "lhsFrac=-1/3", "rhsInt=2", "expFrac=1 2/3"), - Iteration("-fraction+-int", "lhsFrac=-1/3", "rhsInt=-2", "expFrac=-2 1/3") - ) + @Iteration("identity+identity", "lhsFrac=0/1", "rhsInt=0", "expFrac=0/1") + @Iteration("fraction+identity", "lhsFrac=1/1", "rhsInt=0", "expFrac=1") + @Iteration("fraction+int", "lhsFrac=1/3", "rhsInt=2", "expFrac=2 1/3") + @Iteration("wholeNumberFraction+int", "lhsFrac=3/1", "rhsInt=2", "expFrac=5") + @Iteration("commutativity", "lhsFrac=2/1", "rhsInt=3", "expFrac=5") + @Iteration("fraction+-int", "lhsFrac=1/3", "rhsInt=-2", "expFrac=-1 2/3") + @Iteration("-fraction+int", "lhsFrac=-1/3", "rhsInt=2", "expFrac=1 2/3") + @Iteration("-fraction+-int", "lhsFrac=-1/3", "rhsInt=-2", "expFrac=-2 1/3") fun testPlus_fractionAndInt_returnsFraction() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createIntegerReal(rhsInt) @@ -1114,15 +1081,13 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity+identity", "lhsFrac=0/1", "rhsFrac=0/1", "expFrac=0/1"), - Iteration("fraction+identity", "lhsFrac=3/2", "rhsFrac=0/1", "expFrac=1 1/2"), - Iteration("fraction+fraction", "lhsFrac=3/2", "rhsFrac=1/3", "expFrac=1 5/6"), - Iteration("commutativity", "lhsFrac=1/3", "rhsFrac=3/2", "expFrac=1 5/6"), - Iteration("fraction+-fraction", "lhsFrac=1/2", "rhsFrac=-1/3", "expFrac=1/6"), - Iteration("-fraction+fraction", "lhsFrac=-1/2", "rhsFrac=1/3", "expFrac=-1/6"), - Iteration("-fraction+-fraction", "lhsFrac=-1/2", "rhsFrac=-1/3", "expFrac=-5/6") - ) + @Iteration("identity+identity", "lhsFrac=0/1", "rhsFrac=0/1", "expFrac=0/1") + @Iteration("fraction+identity", "lhsFrac=3/2", "rhsFrac=0/1", "expFrac=1 1/2") + @Iteration("fraction+fraction", "lhsFrac=3/2", "rhsFrac=1/3", "expFrac=1 5/6") + @Iteration("commutativity", "lhsFrac=1/3", "rhsFrac=3/2", "expFrac=1 5/6") + @Iteration("fraction+-fraction", "lhsFrac=1/2", "rhsFrac=-1/3", "expFrac=1/6") + @Iteration("-fraction+fraction", "lhsFrac=-1/2", "rhsFrac=1/3", "expFrac=-1/6") + @Iteration("-fraction+-fraction", "lhsFrac=-1/2", "rhsFrac=-1/3", "expFrac=-5/6") fun testPlus_fractionAndFraction_returnsFraction() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createRationalReal(rhsFrac) @@ -1134,16 +1099,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity+identity", "lhsFrac=0/1", "rhsDouble=0.0", "expDouble=0.0"), - Iteration("fraction+identity", "lhsFrac=3/2", "rhsDouble=0.0", "expDouble=1.5"), - Iteration("fraction+double", "lhsFrac=3/2", "rhsDouble=3.14", "expDouble=4.64"), - Iteration("wholeNumberFraction+double", "lhsFrac=3/1", "rhsDouble=2.0", "expDouble=5.0"), - Iteration("commutativity", "lhsFrac=2/1", "rhsDouble=3.0", "expDouble=5.0"), - Iteration("fraction+-double", "lhsFrac=3/2", "rhsDouble=-3.14", "expDouble=-1.64"), - Iteration("-fraction+double", "lhsFrac=-3/2", "rhsDouble=3.14", "expDouble=1.64"), - Iteration("-fraction+-double", "lhsFrac=-3/2", "rhsDouble=-3.14", "expDouble=-4.64") - ) + @Iteration("identity+identity", "lhsFrac=0/1", "rhsDouble=0.0", "expDouble=0.0") + @Iteration("fraction+identity", "lhsFrac=3/2", "rhsDouble=0.0", "expDouble=1.5") + @Iteration("fraction+double", "lhsFrac=3/2", "rhsDouble=3.14", "expDouble=4.64") + @Iteration("wholeNumberFraction+double", "lhsFrac=3/1", "rhsDouble=2.0", "expDouble=5.0") + @Iteration("commutativity", "lhsFrac=2/1", "rhsDouble=3.0", "expDouble=5.0") + @Iteration("fraction+-double", "lhsFrac=3/2", "rhsDouble=-3.14", "expDouble=-1.64") + @Iteration("-fraction+double", "lhsFrac=-3/2", "rhsDouble=3.14", "expDouble=1.64") + @Iteration("-fraction+-double", "lhsFrac=-3/2", "rhsDouble=-3.14", "expDouble=-4.64") fun testPlus_fractionAndDouble_returnsDouble() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createIrrationalReal(rhsDouble) @@ -1154,16 +1117,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity+identity", "lhsDouble=0.0", "rhsInt=0", "expDouble=0.0"), - Iteration("double+identity", "lhsDouble=1.0", "rhsInt=0", "expDouble=1.0"), - Iteration("double+int", "lhsDouble=3.14", "rhsInt=1", "expDouble=4.14"), - Iteration("wholeNumberDouble+int", "lhsDouble=3.0", "rhsInt=1", "expDouble=4.0"), - Iteration("commutativity", "lhsDouble=1.0", "rhsInt=3", "expDouble=4.0"), - Iteration("double+-int", "lhsDouble=3.14", "rhsInt=-1", "expDouble=2.14"), - Iteration("-double+int", "lhsDouble=-3.14", "rhsInt=1", "expDouble=-2.14"), - Iteration("-double+-int", "lhsDouble=-3.14", "rhsInt=-1", "expDouble=-4.14") - ) + @Iteration("identity+identity", "lhsDouble=0.0", "rhsInt=0", "expDouble=0.0") + @Iteration("double+identity", "lhsDouble=1.0", "rhsInt=0", "expDouble=1.0") + @Iteration("double+int", "lhsDouble=3.14", "rhsInt=1", "expDouble=4.14") + @Iteration("wholeNumberDouble+int", "lhsDouble=3.0", "rhsInt=1", "expDouble=4.0") + @Iteration("commutativity", "lhsDouble=1.0", "rhsInt=3", "expDouble=4.0") + @Iteration("double+-int", "lhsDouble=3.14", "rhsInt=-1", "expDouble=2.14") + @Iteration("-double+int", "lhsDouble=-3.14", "rhsInt=1", "expDouble=-2.14") + @Iteration("-double+-int", "lhsDouble=-3.14", "rhsInt=-1", "expDouble=-4.14") fun testPlus_doubleAndInt_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createIntegerReal(rhsInt) @@ -1174,16 +1135,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity+identity", "lhsDouble=0.0", "rhsFrac=0/1", "expDouble=0.0"), - Iteration("double+identity", "lhsDouble=3.14", "rhsFrac=0/1", "expDouble=3.14"), - Iteration("double+fraction", "lhsDouble=3.14", "rhsFrac=3/2", "expDouble=4.64"), - Iteration("double+wholeNumberFraction", "lhsDouble=2.0", "rhsFrac=3/1", "expDouble=5.0"), - Iteration("commutativity", "lhsDouble=3.0", "rhsFrac=2/1", "expDouble=5.0"), - Iteration("double+-fraction", "lhsDouble=3.14", "rhsFrac=-3/2", "expDouble=1.64"), - Iteration("-double+fraction", "lhsDouble=-3.14", "rhsFrac=3/2", "expDouble=-1.64"), - Iteration("-double+-fraction", "lhsDouble=-3.14", "rhsFrac=-3/2", "expDouble=-4.64") - ) + @Iteration("identity+identity", "lhsDouble=0.0", "rhsFrac=0/1", "expDouble=0.0") + @Iteration("double+identity", "lhsDouble=3.14", "rhsFrac=0/1", "expDouble=3.14") + @Iteration("double+fraction", "lhsDouble=3.14", "rhsFrac=3/2", "expDouble=4.64") + @Iteration("double+wholeNumberFraction", "lhsDouble=2.0", "rhsFrac=3/1", "expDouble=5.0") + @Iteration("commutativity", "lhsDouble=3.0", "rhsFrac=2/1", "expDouble=5.0") + @Iteration("double+-fraction", "lhsDouble=3.14", "rhsFrac=-3/2", "expDouble=1.64") + @Iteration("-double+fraction", "lhsDouble=-3.14", "rhsFrac=3/2", "expDouble=-1.64") + @Iteration("-double+-fraction", "lhsDouble=-3.14", "rhsFrac=-3/2", "expDouble=-4.64") fun testPlus_doubleAndFraction_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createRationalReal(rhsFrac) @@ -1194,15 +1153,13 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity+identity", "lhsDouble=0.0", "rhsDouble=0.0", "expDouble=0.0"), - Iteration("double+identity", "lhsDouble=1.0", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("double+double", "lhsDouble=3.14", "rhsDouble=2.7", "expDouble=5.84"), - Iteration("commutativity", "lhsDouble=2.7", "rhsDouble=3.14", "expDouble=5.84"), - Iteration("double+-double", "lhsDouble=3.14", "rhsDouble=-2.7", "expDouble=0.44"), - Iteration("-double+double", "lhsDouble=-3.14", "rhsDouble=2.7", "expDouble=-0.44"), - Iteration("-double+-double", "lhsDouble=-3.14", "rhsDouble=-2.7", "expDouble=-5.84") - ) + @Iteration("identity+identity", "lhsDouble=0.0", "rhsDouble=0.0", "expDouble=0.0") + @Iteration("double+identity", "lhsDouble=1.0", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("double+double", "lhsDouble=3.14", "rhsDouble=2.7", "expDouble=5.84") + @Iteration("commutativity", "lhsDouble=2.7", "rhsDouble=3.14", "expDouble=5.84") + @Iteration("double+-double", "lhsDouble=3.14", "rhsDouble=-2.7", "expDouble=0.44") + @Iteration("-double+double", "lhsDouble=-3.14", "rhsDouble=2.7", "expDouble=-0.44") + @Iteration("-double+-double", "lhsDouble=-3.14", "rhsDouble=-2.7", "expDouble=-5.84") fun testPlus_doubleAndDouble_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createIrrationalReal(rhsDouble) @@ -1215,15 +1172,13 @@ class RealExtensionsTest { // Subtraction tests. @Test - @RunParameterized( - Iteration("identity-identity", "lhsInt=0", "rhsInt=0", "expInt=0"), - Iteration("int-identity", "lhsInt=1", "rhsInt=0", "expInt=1"), - Iteration("int-int", "lhsInt=1", "rhsInt=2", "expInt=-1"), - Iteration("anticommutativity", "lhsInt=2", "rhsInt=1", "expInt=1"), - Iteration("int--int", "lhsInt=1", "rhsInt=-2", "expInt=3"), - Iteration("-int-int", "lhsInt=-1", "rhsInt=2", "expInt=-3"), - Iteration("-int--int", "lhsInt=-1", "rhsInt=-2", "expInt=1") - ) + @Iteration("identity-identity", "lhsInt=0", "rhsInt=0", "expInt=0") + @Iteration("int-identity", "lhsInt=1", "rhsInt=0", "expInt=1") + @Iteration("int-int", "lhsInt=1", "rhsInt=2", "expInt=-1") + @Iteration("anticommutativity", "lhsInt=2", "rhsInt=1", "expInt=1") + @Iteration("int--int", "lhsInt=1", "rhsInt=-2", "expInt=3") + @Iteration("-int-int", "lhsInt=-1", "rhsInt=2", "expInt=-3") + @Iteration("-int--int", "lhsInt=-1", "rhsInt=-2", "expInt=1") fun testMinus_intAndInt_returnsInt() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIntegerReal(rhsInt) @@ -1234,16 +1189,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity-identity", "lhsInt=0", "rhsFrac=0/1", "expFrac=0/1"), - Iteration("int-identity", "lhsInt=1", "rhsFrac=0/1", "expFrac=1"), - Iteration("int-fraction", "lhsInt=2", "rhsFrac=1/3", "expFrac=1 2/3"), - Iteration("int-wholeNumberFraction", "lhsInt=2", "rhsFrac=3/1", "expFrac=-1"), - Iteration("anticommutativity", "lhsInt=3", "rhsFrac=2/1", "expFrac=1"), - Iteration("int--fraction", "lhsInt=2", "rhsFrac=-1/3", "expFrac=2 1/3"), - Iteration("-int-fraction", "lhsInt=-2", "rhsFrac=1/3", "expFrac=-2 1/3"), - Iteration("-int--fraction", "lhsInt=-2", "rhsFrac=-1/3", "expFrac=-1 2/3") - ) + @Iteration("identity-identity", "lhsInt=0", "rhsFrac=0/1", "expFrac=0/1") + @Iteration("int-identity", "lhsInt=1", "rhsFrac=0/1", "expFrac=1") + @Iteration("int-fraction", "lhsInt=2", "rhsFrac=1/3", "expFrac=1 2/3") + @Iteration("int-wholeNumberFraction", "lhsInt=2", "rhsFrac=3/1", "expFrac=-1") + @Iteration("anticommutativity", "lhsInt=3", "rhsFrac=2/1", "expFrac=1") + @Iteration("int--fraction", "lhsInt=2", "rhsFrac=-1/3", "expFrac=2 1/3") + @Iteration("-int-fraction", "lhsInt=-2", "rhsFrac=1/3", "expFrac=-2 1/3") + @Iteration("-int--fraction", "lhsInt=-2", "rhsFrac=-1/3", "expFrac=-1 2/3") fun testMinus_intAndFraction_returnsFraction() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createRationalReal(rhsFrac) @@ -1255,16 +1208,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity-identity", "lhsInt=0", "rhsDouble=0.0", "expDouble=0.0"), - Iteration("int-identity", "lhsInt=1", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("int-double", "lhsInt=1", "rhsDouble=3.14", "expDouble=-2.14"), - Iteration("int-wholeNumberDouble", "lhsInt=1", "rhsDouble=3.0", "expDouble=-2.0"), - Iteration("anticommutativity", "lhsInt=3", "rhsDouble=1.0", "expDouble=2.0"), - Iteration("int--double", "lhsInt=1", "rhsDouble=-3.14", "expDouble=4.14"), - Iteration("-int-double", "lhsInt=-1", "rhsDouble=3.14", "expDouble=-4.14"), - Iteration("-int--double", "lhsInt=-1", "rhsDouble=-3.14", "expDouble=2.14") - ) + @Iteration("identity-identity", "lhsInt=0", "rhsDouble=0.0", "expDouble=0.0") + @Iteration("int-identity", "lhsInt=1", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("int-double", "lhsInt=1", "rhsDouble=3.14", "expDouble=-2.14") + @Iteration("int-wholeNumberDouble", "lhsInt=1", "rhsDouble=3.0", "expDouble=-2.0") + @Iteration("anticommutativity", "lhsInt=3", "rhsDouble=1.0", "expDouble=2.0") + @Iteration("int--double", "lhsInt=1", "rhsDouble=-3.14", "expDouble=4.14") + @Iteration("-int-double", "lhsInt=-1", "rhsDouble=3.14", "expDouble=-4.14") + @Iteration("-int--double", "lhsInt=-1", "rhsDouble=-3.14", "expDouble=2.14") fun testMinus_intAndDouble_returnsDouble() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIrrationalReal(rhsDouble) @@ -1275,16 +1226,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity-identity", "lhsFrac=0/1", "rhsInt=0", "expFrac=0/1"), - Iteration("fraction-identity", "lhsFrac=1/1", "rhsInt=0", "expFrac=1"), - Iteration("fraction-int", "lhsFrac=1/3", "rhsInt=2", "expFrac=-1 2/3"), - Iteration("wholeNumberFraction-int", "lhsFrac=3/1", "rhsInt=2", "expFrac=1"), - Iteration("anticommutativity", "lhsFrac=2/1", "rhsInt=3", "expFrac=-1"), - Iteration("fraction--int", "lhsFrac=1/3", "rhsInt=-2", "expFrac=2 1/3"), - Iteration("-fraction-int", "lhsFrac=-1/3", "rhsInt=2", "expFrac=-2 1/3"), - Iteration("-fraction--int", "lhsFrac=-1/3", "rhsInt=-2", "expFrac=1 2/3") - ) + @Iteration("identity-identity", "lhsFrac=0/1", "rhsInt=0", "expFrac=0/1") + @Iteration("fraction-identity", "lhsFrac=1/1", "rhsInt=0", "expFrac=1") + @Iteration("fraction-int", "lhsFrac=1/3", "rhsInt=2", "expFrac=-1 2/3") + @Iteration("wholeNumberFraction-int", "lhsFrac=3/1", "rhsInt=2", "expFrac=1") + @Iteration("anticommutativity", "lhsFrac=2/1", "rhsInt=3", "expFrac=-1") + @Iteration("fraction--int", "lhsFrac=1/3", "rhsInt=-2", "expFrac=2 1/3") + @Iteration("-fraction-int", "lhsFrac=-1/3", "rhsInt=2", "expFrac=-2 1/3") + @Iteration("-fraction--int", "lhsFrac=-1/3", "rhsInt=-2", "expFrac=1 2/3") fun testMinus_fractionAndInt_returnsFraction() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createIntegerReal(rhsInt) @@ -1296,15 +1245,13 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity-identity", "lhsFrac=0/1", "rhsFrac=0/1", "expFrac=0/1"), - Iteration("fraction-identity", "lhsFrac=3/2", "rhsFrac=0/1", "expFrac=1 1/2"), - Iteration("fraction-fraction", "lhsFrac=3/2", "rhsFrac=1/3", "expFrac=1 1/6"), - Iteration("anticommutativity", "lhsFrac=1/3", "rhsFrac=3/2", "expFrac=-1 1/6"), - Iteration("fraction--fraction", "lhsFrac=1/2", "rhsFrac=-1/3", "expFrac=5/6"), - Iteration("-fraction-fraction", "lhsFrac=-1/2", "rhsFrac=1/3", "expFrac=-5/6"), - Iteration("-fraction--fraction", "lhsFrac=-1/2", "rhsFrac=-1/3", "expFrac=-1/6") - ) + @Iteration("identity-identity", "lhsFrac=0/1", "rhsFrac=0/1", "expFrac=0/1") + @Iteration("fraction-identity", "lhsFrac=3/2", "rhsFrac=0/1", "expFrac=1 1/2") + @Iteration("fraction-fraction", "lhsFrac=3/2", "rhsFrac=1/3", "expFrac=1 1/6") + @Iteration("anticommutativity", "lhsFrac=1/3", "rhsFrac=3/2", "expFrac=-1 1/6") + @Iteration("fraction--fraction", "lhsFrac=1/2", "rhsFrac=-1/3", "expFrac=5/6") + @Iteration("-fraction-fraction", "lhsFrac=-1/2", "rhsFrac=1/3", "expFrac=-5/6") + @Iteration("-fraction--fraction", "lhsFrac=-1/2", "rhsFrac=-1/3", "expFrac=-1/6") fun testMinus_fractionAndFraction_returnsFraction() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createRationalReal(rhsFrac) @@ -1316,16 +1263,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity-identity", "lhsFrac=0/1", "rhsDouble=0.0", "expDouble=0.0"), - Iteration("fraction-identity", "lhsFrac=3/2", "rhsDouble=0.0", "expDouble=1.5"), - Iteration("fraction-double", "lhsFrac=3/2", "rhsDouble=3.14", "expDouble=-1.64"), - Iteration("wholeNumberFraction-double", "lhsFrac=3/1", "rhsDouble=2.0", "expDouble=1.0"), - Iteration("anticommutativity", "lhsFrac=2/1", "rhsDouble=3.0", "expDouble=-1.0"), - Iteration("fraction--double", "lhsFrac=3/2", "rhsDouble=-3.14", "expDouble=4.64"), - Iteration("-fraction-double", "lhsFrac=-3/2", "rhsDouble=3.14", "expDouble=-4.64"), - Iteration("-fraction--double", "lhsFrac=-3/2", "rhsDouble=-3.14", "expDouble=1.64") - ) + @Iteration("identity-identity", "lhsFrac=0/1", "rhsDouble=0.0", "expDouble=0.0") + @Iteration("fraction-identity", "lhsFrac=3/2", "rhsDouble=0.0", "expDouble=1.5") + @Iteration("fraction-double", "lhsFrac=3/2", "rhsDouble=3.14", "expDouble=-1.64") + @Iteration("wholeNumberFraction-double", "lhsFrac=3/1", "rhsDouble=2.0", "expDouble=1.0") + @Iteration("anticommutativity", "lhsFrac=2/1", "rhsDouble=3.0", "expDouble=-1.0") + @Iteration("fraction--double", "lhsFrac=3/2", "rhsDouble=-3.14", "expDouble=4.64") + @Iteration("-fraction-double", "lhsFrac=-3/2", "rhsDouble=3.14", "expDouble=-4.64") + @Iteration("-fraction--double", "lhsFrac=-3/2", "rhsDouble=-3.14", "expDouble=1.64") fun testMinus_fractionAndDouble_returnsDouble() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createIrrationalReal(rhsDouble) @@ -1336,16 +1281,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity-identity", "lhsDouble=0.0", "rhsInt=0", "expDouble=0.0"), - Iteration("double-identity", "lhsDouble=1.0", "rhsInt=0", "expDouble=1.0"), - Iteration("double-int", "lhsDouble=3.14", "rhsInt=1", "expDouble=2.14"), - Iteration("wholeNumberDouble-int", "lhsDouble=3.0", "rhsInt=1", "expDouble=2.0"), - Iteration("anticommutativity", "lhsDouble=1.0", "rhsInt=3", "expDouble=-2.0"), - Iteration("double--int", "lhsDouble=3.14", "rhsInt=-1", "expDouble=4.14"), - Iteration("-double-int", "lhsDouble=-3.14", "rhsInt=1", "expDouble=-4.14"), - Iteration("-double--int", "lhsDouble=-3.14", "rhsInt=-1", "expDouble=-2.14") - ) + @Iteration("identity-identity", "lhsDouble=0.0", "rhsInt=0", "expDouble=0.0") + @Iteration("double-identity", "lhsDouble=1.0", "rhsInt=0", "expDouble=1.0") + @Iteration("double-int", "lhsDouble=3.14", "rhsInt=1", "expDouble=2.14") + @Iteration("wholeNumberDouble-int", "lhsDouble=3.0", "rhsInt=1", "expDouble=2.0") + @Iteration("anticommutativity", "lhsDouble=1.0", "rhsInt=3", "expDouble=-2.0") + @Iteration("double--int", "lhsDouble=3.14", "rhsInt=-1", "expDouble=4.14") + @Iteration("-double-int", "lhsDouble=-3.14", "rhsInt=1", "expDouble=-4.14") + @Iteration("-double--int", "lhsDouble=-3.14", "rhsInt=-1", "expDouble=-2.14") fun testMinus_doubleAndInt_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createIntegerReal(rhsInt) @@ -1356,16 +1299,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity-identity", "lhsDouble=0.0", "rhsFrac=0/1", "expDouble=0.0"), - Iteration("double-identity", "lhsDouble=3.14", "rhsFrac=0/1", "expDouble=3.14"), - Iteration("double-fraction", "lhsDouble=3.14", "rhsFrac=3/2", "expDouble=1.64"), - Iteration("double-wholeNumberFraction", "lhsDouble=2.0", "rhsFrac=3/1", "expDouble=-1.0"), - Iteration("anticommutativity", "lhsDouble=3.0", "rhsFrac=2/1", "expDouble=1.0"), - Iteration("double--fraction", "lhsDouble=3.14", "rhsFrac=-3/2", "expDouble=4.64"), - Iteration("-double-fraction", "lhsDouble=-3.14", "rhsFrac=3/2", "expDouble=-4.64"), - Iteration("-double--fraction", "lhsDouble=-3.14", "rhsFrac=-3/2", "expDouble=-1.64") - ) + @Iteration("identity-identity", "lhsDouble=0.0", "rhsFrac=0/1", "expDouble=0.0") + @Iteration("double-identity", "lhsDouble=3.14", "rhsFrac=0/1", "expDouble=3.14") + @Iteration("double-fraction", "lhsDouble=3.14", "rhsFrac=3/2", "expDouble=1.64") + @Iteration("double-wholeNumberFraction", "lhsDouble=2.0", "rhsFrac=3/1", "expDouble=-1.0") + @Iteration("anticommutativity", "lhsDouble=3.0", "rhsFrac=2/1", "expDouble=1.0") + @Iteration("double--fraction", "lhsDouble=3.14", "rhsFrac=-3/2", "expDouble=4.64") + @Iteration("-double-fraction", "lhsDouble=-3.14", "rhsFrac=3/2", "expDouble=-4.64") + @Iteration("-double--fraction", "lhsDouble=-3.14", "rhsFrac=-3/2", "expDouble=-1.64") fun testMinus_doubleAndFraction_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createRationalReal(rhsFrac) @@ -1376,15 +1317,13 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity-identity", "lhsDouble=0.0", "rhsDouble=0.0", "expDouble=0.0"), - Iteration("double-identity", "lhsDouble=1.0", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("double-double", "lhsDouble=3.14", "rhsDouble=2.7", "expDouble=0.44"), - Iteration("anticommutativity", "lhsDouble=2.7", "rhsDouble=3.14", "expDouble=-0.44"), - Iteration("double--double", "lhsDouble=3.14", "rhsDouble=-2.7", "expDouble=5.84"), - Iteration("-double-double", "lhsDouble=-3.14", "rhsDouble=2.7", "expDouble=-5.84"), - Iteration("-double--double", "lhsDouble=-3.14", "rhsDouble=-2.7", "expDouble=-0.44") - ) + @Iteration("identity-identity", "lhsDouble=0.0", "rhsDouble=0.0", "expDouble=0.0") + @Iteration("double-identity", "lhsDouble=1.0", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("double-double", "lhsDouble=3.14", "rhsDouble=2.7", "expDouble=0.44") + @Iteration("anticommutativity", "lhsDouble=2.7", "rhsDouble=3.14", "expDouble=-0.44") + @Iteration("double--double", "lhsDouble=3.14", "rhsDouble=-2.7", "expDouble=5.84") + @Iteration("-double-double", "lhsDouble=-3.14", "rhsDouble=2.7", "expDouble=-5.84") + @Iteration("-double--double", "lhsDouble=-3.14", "rhsDouble=-2.7", "expDouble=-0.44") fun testMinus_doubleAndDouble_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createIrrationalReal(rhsDouble) @@ -1397,15 +1336,13 @@ class RealExtensionsTest { // Multiplication tests. @Test - @RunParameterized( - Iteration("identity*identity", "lhsInt=1", "rhsInt=1", "expInt=1"), - Iteration("int*identity", "lhsInt=2", "rhsInt=1", "expInt=2"), - Iteration("int*int", "lhsInt=3", "rhsInt=2", "expInt=6"), - Iteration("commutativity", "lhsInt=2", "rhsInt=3", "expInt=6"), - Iteration("int*-int", "lhsInt=3", "rhsInt=-2", "expInt=-6"), - Iteration("-int*int", "lhsInt=-3", "rhsInt=2", "expInt=-6"), - Iteration("-int*-int", "lhsInt=-3", "rhsInt=-2", "expInt=6") - ) + @Iteration("identity*identity", "lhsInt=1", "rhsInt=1", "expInt=1") + @Iteration("int*identity", "lhsInt=2", "rhsInt=1", "expInt=2") + @Iteration("int*int", "lhsInt=3", "rhsInt=2", "expInt=6") + @Iteration("commutativity", "lhsInt=2", "rhsInt=3", "expInt=6") + @Iteration("int*-int", "lhsInt=3", "rhsInt=-2", "expInt=-6") + @Iteration("-int*int", "lhsInt=-3", "rhsInt=2", "expInt=-6") + @Iteration("-int*-int", "lhsInt=-3", "rhsInt=-2", "expInt=6") fun testTimes_intAndInt_returnsInt() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIntegerReal(rhsInt) @@ -1416,16 +1353,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity*identity", "lhsInt=1", "rhsFrac=1", "expFrac=1"), - Iteration("int*identity", "lhsInt=2", "rhsFrac=1", "expFrac=2"), - Iteration("int*fraction", "lhsInt=2", "rhsFrac=1/3", "expFrac=2/3"), - Iteration("int*wholeNumberFraction", "lhsInt=2", "rhsFrac=3/1", "expFrac=6"), - Iteration("commutativity", "lhsInt=3", "rhsFrac=2/1", "expFrac=6"), - Iteration("int*-fraction", "lhsInt=2", "rhsFrac=-1/3", "expFrac=-2/3"), - Iteration("-int*fraction", "lhsInt=-2", "rhsFrac=1/3", "expFrac=-2/3"), - Iteration("-int*-fraction", "lhsInt=-2", "rhsFrac=-1/3", "expFrac=2/3") - ) + @Iteration("identity*identity", "lhsInt=1", "rhsFrac=1", "expFrac=1") + @Iteration("int*identity", "lhsInt=2", "rhsFrac=1", "expFrac=2") + @Iteration("int*fraction", "lhsInt=2", "rhsFrac=1/3", "expFrac=2/3") + @Iteration("int*wholeNumberFraction", "lhsInt=2", "rhsFrac=3/1", "expFrac=6") + @Iteration("commutativity", "lhsInt=3", "rhsFrac=2/1", "expFrac=6") + @Iteration("int*-fraction", "lhsInt=2", "rhsFrac=-1/3", "expFrac=-2/3") + @Iteration("-int*fraction", "lhsInt=-2", "rhsFrac=1/3", "expFrac=-2/3") + @Iteration("-int*-fraction", "lhsInt=-2", "rhsFrac=-1/3", "expFrac=2/3") fun testTimes_intAndFraction_returnsFraction() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createRationalReal(rhsFrac) @@ -1437,16 +1372,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity*identity", "lhsInt=1", "rhsDouble=1.0", "expDouble=1.0"), - Iteration("int*identity", "lhsInt=2", "rhsDouble=1.0", "expDouble=2.0"), - Iteration("int*double", "lhsInt=2", "rhsDouble=3.14", "expDouble=6.28"), - Iteration("int*wholeNumberDouble", "lhsInt=2", "rhsDouble=3.0", "expDouble=6.0"), - Iteration("commutativity", "lhsInt=3", "rhsDouble=2.0", "expDouble=6.0"), - Iteration("int*-double", "lhsInt=2", "rhsDouble=-3.14", "expDouble=-6.28"), - Iteration("-int*double", "lhsInt=-2", "rhsDouble=3.14", "expDouble=-6.28"), - Iteration("-int*-double", "lhsInt=-2", "rhsDouble=-3.14", "expDouble=6.28") - ) + @Iteration("identity*identity", "lhsInt=1", "rhsDouble=1.0", "expDouble=1.0") + @Iteration("int*identity", "lhsInt=2", "rhsDouble=1.0", "expDouble=2.0") + @Iteration("int*double", "lhsInt=2", "rhsDouble=3.14", "expDouble=6.28") + @Iteration("int*wholeNumberDouble", "lhsInt=2", "rhsDouble=3.0", "expDouble=6.0") + @Iteration("commutativity", "lhsInt=3", "rhsDouble=2.0", "expDouble=6.0") + @Iteration("int*-double", "lhsInt=2", "rhsDouble=-3.14", "expDouble=-6.28") + @Iteration("-int*double", "lhsInt=-2", "rhsDouble=3.14", "expDouble=-6.28") + @Iteration("-int*-double", "lhsInt=-2", "rhsDouble=-3.14", "expDouble=6.28") fun testTimes_intAndDouble_returnsDouble() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIrrationalReal(rhsDouble) @@ -1457,16 +1390,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity*identity", "lhsFrac=1/1", "rhsInt=1", "expFrac=1"), - Iteration("fraction*identity", "lhsFrac=2/1", "rhsInt=1", "expFrac=2"), - Iteration("fraction*int", "lhsFrac=1/3", "rhsInt=2", "expFrac=2/3"), - Iteration("wholeNumberFraction*int", "lhsFrac=3/1", "rhsInt=2", "expFrac=6"), - Iteration("commutativity", "lhsFrac=2/1", "rhsInt=3", "expFrac=6"), - Iteration("fraction*-int", "lhsFrac=1/3", "rhsInt=-2", "expFrac=-2/3"), - Iteration("-fraction*int", "lhsFrac=-1/3", "rhsInt=2", "expFrac=-2/3"), - Iteration("-fraction*-int", "lhsFrac=-1/3", "rhsInt=-2", "expFrac=2/3") - ) + @Iteration("identity*identity", "lhsFrac=1/1", "rhsInt=1", "expFrac=1") + @Iteration("fraction*identity", "lhsFrac=2/1", "rhsInt=1", "expFrac=2") + @Iteration("fraction*int", "lhsFrac=1/3", "rhsInt=2", "expFrac=2/3") + @Iteration("wholeNumberFraction*int", "lhsFrac=3/1", "rhsInt=2", "expFrac=6") + @Iteration("commutativity", "lhsFrac=2/1", "rhsInt=3", "expFrac=6") + @Iteration("fraction*-int", "lhsFrac=1/3", "rhsInt=-2", "expFrac=-2/3") + @Iteration("-fraction*int", "lhsFrac=-1/3", "rhsInt=2", "expFrac=-2/3") + @Iteration("-fraction*-int", "lhsFrac=-1/3", "rhsInt=-2", "expFrac=2/3") fun testTimes_fractionAndInt_returnsFraction() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createIntegerReal(rhsInt) @@ -1478,15 +1409,13 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity*identity", "lhsFrac=1/1", "rhsFrac=1/1", "expFrac=1"), - Iteration("fraction*identity", "lhsFrac=3/2", "rhsFrac=1/1", "expFrac=1 1/2"), - Iteration("fraction*fraction", "lhsFrac=3/2", "rhsFrac=4/7", "expFrac=6/7"), - Iteration("commutativity", "lhsFrac=4/7", "rhsFrac=3/2", "expFrac=6/7"), - Iteration("fraction*-fraction", "lhsFrac=1 3/9", "rhsFrac=-8/11", "expFrac=-32/33"), - Iteration("-fraction*fraction", "lhsFrac=-1 3/9", "rhsFrac=8/11", "expFrac=-32/33"), - Iteration("-fraction*-fraction", "lhsFrac=-1 3/9", "rhsFrac=-8/11", "expFrac=32/33") - ) + @Iteration("identity*identity", "lhsFrac=1/1", "rhsFrac=1/1", "expFrac=1") + @Iteration("fraction*identity", "lhsFrac=3/2", "rhsFrac=1/1", "expFrac=1 1/2") + @Iteration("fraction*fraction", "lhsFrac=3/2", "rhsFrac=4/7", "expFrac=6/7") + @Iteration("commutativity", "lhsFrac=4/7", "rhsFrac=3/2", "expFrac=6/7") + @Iteration("fraction*-fraction", "lhsFrac=1 3/9", "rhsFrac=-8/11", "expFrac=-32/33") + @Iteration("-fraction*fraction", "lhsFrac=-1 3/9", "rhsFrac=8/11", "expFrac=-32/33") + @Iteration("-fraction*-fraction", "lhsFrac=-1 3/9", "rhsFrac=-8/11", "expFrac=32/33") fun testTimes_fractionAndFraction_returnsFraction() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createRationalReal(rhsFrac) @@ -1498,16 +1427,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity*identity", "lhsFrac=1/1", "rhsDouble=1.0", "expDouble=1.0"), - Iteration("fraction*identity", "lhsFrac=3/2", "rhsDouble=1.0", "expDouble=1.5"), - Iteration("fraction*double", "lhsFrac=3/2", "rhsDouble=3.14", "expDouble=4.71"), - Iteration("wholeNumberFraction*double", "lhsFrac=3/1", "rhsDouble=2.0", "expDouble=6.0"), - Iteration("commutativity", "lhsFrac=2/1", "rhsDouble=3.0", "expDouble=6.0"), - Iteration("fraction*-double", "lhsFrac=1 3/2", "rhsDouble=-3.14", "expDouble=-7.85"), - Iteration("-fraction*double", "lhsFrac=-1 3/2", "rhsDouble=3.14", "expDouble=-7.85"), - Iteration("-fraction*-double", "lhsFrac=-1 3/2", "rhsDouble=-3.14", "expDouble=7.85") - ) + @Iteration("identity*identity", "lhsFrac=1/1", "rhsDouble=1.0", "expDouble=1.0") + @Iteration("fraction*identity", "lhsFrac=3/2", "rhsDouble=1.0", "expDouble=1.5") + @Iteration("fraction*double", "lhsFrac=3/2", "rhsDouble=3.14", "expDouble=4.71") + @Iteration("wholeNumberFraction*double", "lhsFrac=3/1", "rhsDouble=2.0", "expDouble=6.0") + @Iteration("commutativity", "lhsFrac=2/1", "rhsDouble=3.0", "expDouble=6.0") + @Iteration("fraction*-double", "lhsFrac=1 3/2", "rhsDouble=-3.14", "expDouble=-7.85") + @Iteration("-fraction*double", "lhsFrac=-1 3/2", "rhsDouble=3.14", "expDouble=-7.85") + @Iteration("-fraction*-double", "lhsFrac=-1 3/2", "rhsDouble=-3.14", "expDouble=7.85") fun testTimes_fractionAndDouble_returnsDouble() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createIrrationalReal(rhsDouble) @@ -1518,16 +1445,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity*identity", "lhsDouble=1.0", "rhsInt=1", "expDouble=1.0"), - Iteration("double*identity", "lhsDouble=2.0", "rhsInt=1", "expDouble=2.0"), - Iteration("double*int", "lhsDouble=3.14", "rhsInt=2", "expDouble=6.28"), - Iteration("wholeNumberDouble*int", "lhsDouble=3.0", "rhsInt=2", "expDouble=6"), - Iteration("commutativity", "lhsDouble=2.0", "rhsInt=3", "expDouble=6.0"), - Iteration("double*-int", "lhsDouble=3.14", "rhsInt=-2", "expDouble=-6.28"), - Iteration("-double*int", "lhsDouble=-3.14", "rhsInt=2", "expDouble=-6.28"), - Iteration("-double*-int", "lhsDouble=-3.14", "rhsInt=-2", "expDouble=6.28") - ) + @Iteration("identity*identity", "lhsDouble=1.0", "rhsInt=1", "expDouble=1.0") + @Iteration("double*identity", "lhsDouble=2.0", "rhsInt=1", "expDouble=2.0") + @Iteration("double*int", "lhsDouble=3.14", "rhsInt=2", "expDouble=6.28") + @Iteration("wholeNumberDouble*int", "lhsDouble=3.0", "rhsInt=2", "expDouble=6") + @Iteration("commutativity", "lhsDouble=2.0", "rhsInt=3", "expDouble=6.0") + @Iteration("double*-int", "lhsDouble=3.14", "rhsInt=-2", "expDouble=-6.28") + @Iteration("-double*int", "lhsDouble=-3.14", "rhsInt=2", "expDouble=-6.28") + @Iteration("-double*-int", "lhsDouble=-3.14", "rhsInt=-2", "expDouble=6.28") fun testTimes_doubleAndInt_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createIntegerReal(rhsInt) @@ -1538,16 +1463,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity*identity", "lhsDouble=1.0", "rhsFrac=1/1", "expDouble=1.0"), - Iteration("double*identity", "lhsDouble=2.0", "rhsFrac=1/1", "expDouble=2.0"), - Iteration("double*fraction", "lhsDouble=3.14", "rhsFrac=3/2", "expDouble=4.71"), - Iteration("double*wholeNumberFraction", "lhsDouble=2.0", "rhsFrac=3/1", "expDouble=6.0"), - Iteration("commutativity", "lhsDouble=3.0", "rhsFrac=2/1", "expDouble=6.0"), - Iteration("double*-fraction", "lhsDouble=3.14", "rhsFrac=-1 3/2", "expDouble=-7.85"), - Iteration("-double*fraction", "lhsDouble=-3.14", "rhsFrac=1 3/2", "expDouble=-7.85"), - Iteration("-double*-fraction", "lhsDouble=-3.14", "rhsFrac=-1 3/2", "expDouble=7.85") - ) + @Iteration("identity*identity", "lhsDouble=1.0", "rhsFrac=1/1", "expDouble=1.0") + @Iteration("double*identity", "lhsDouble=2.0", "rhsFrac=1/1", "expDouble=2.0") + @Iteration("double*fraction", "lhsDouble=3.14", "rhsFrac=3/2", "expDouble=4.71") + @Iteration("double*wholeNumberFraction", "lhsDouble=2.0", "rhsFrac=3/1", "expDouble=6.0") + @Iteration("commutativity", "lhsDouble=3.0", "rhsFrac=2/1", "expDouble=6.0") + @Iteration("double*-fraction", "lhsDouble=3.14", "rhsFrac=-1 3/2", "expDouble=-7.85") + @Iteration("-double*fraction", "lhsDouble=-3.14", "rhsFrac=1 3/2", "expDouble=-7.85") + @Iteration("-double*-fraction", "lhsDouble=-3.14", "rhsFrac=-1 3/2", "expDouble=7.85") fun testTimes_doubleAndFraction_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createRationalReal(rhsFrac) @@ -1558,15 +1481,13 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity*identity", "lhsDouble=1.0", "rhsDouble=1.0", "expDouble=1.0"), - Iteration("double*identity", "lhsDouble=2.0", "rhsDouble=1.0", "expDouble=2.0"), - Iteration("double*double", "lhsDouble=3.14", "rhsDouble=2.7", "expDouble=8.478"), - Iteration("commutativity", "lhsDouble=2.7", "rhsDouble=3.14", "expDouble=8.478"), - Iteration("double*-double", "lhsDouble=3.14", "rhsDouble=-2.7", "expDouble=-8.478"), - Iteration("-double*double", "lhsDouble=-3.14", "rhsDouble=2.7", "expDouble=-8.478"), - Iteration("-double*-double", "lhsDouble=-3.14", "rhsDouble=-2.7", "expDouble=8.478") - ) + @Iteration("identity*identity", "lhsDouble=1.0", "rhsDouble=1.0", "expDouble=1.0") + @Iteration("double*identity", "lhsDouble=2.0", "rhsDouble=1.0", "expDouble=2.0") + @Iteration("double*double", "lhsDouble=3.14", "rhsDouble=2.7", "expDouble=8.478") + @Iteration("commutativity", "lhsDouble=2.7", "rhsDouble=3.14", "expDouble=8.478") + @Iteration("double*-double", "lhsDouble=3.14", "rhsDouble=-2.7", "expDouble=-8.478") + @Iteration("-double*double", "lhsDouble=-3.14", "rhsDouble=2.7", "expDouble=-8.478") + @Iteration("-double*-double", "lhsDouble=-3.14", "rhsDouble=-2.7", "expDouble=8.478") fun testTimes_doubleAndDouble_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createIrrationalReal(rhsDouble) @@ -1579,14 +1500,12 @@ class RealExtensionsTest { // Division tests. @Test - @RunParameterized( - Iteration("identity/identity", "lhsInt=1", "rhsInt=1", "expInt=1"), - Iteration("int/identity", "lhsInt=2", "rhsInt=1", "expInt=2"), - Iteration("int/int", "lhsInt=8", "rhsInt=2", "expInt=4"), - Iteration("int/-int", "lhsInt=8", "rhsInt=-2", "expInt=-4"), - Iteration("-int/int", "lhsInt=-8", "rhsInt=2", "expInt=-4"), - Iteration("-int/-int", "lhsInt=-8", "rhsInt=-2", "expInt=4") - ) + @Iteration("identity/identity", "lhsInt=1", "rhsInt=1", "expInt=1") + @Iteration("int/identity", "lhsInt=2", "rhsInt=1", "expInt=2") + @Iteration("int/int", "lhsInt=8", "rhsInt=2", "expInt=4") + @Iteration("int/-int", "lhsInt=8", "rhsInt=-2", "expInt=-4") + @Iteration("-int/int", "lhsInt=-8", "rhsInt=2", "expInt=-4") + @Iteration("-int/-int", "lhsInt=-8", "rhsInt=-2", "expInt=4") fun testDiv_intAndInt_divides_returnsInt() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIntegerReal(rhsInt) @@ -1598,13 +1517,11 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("int/int", "lhsInt=7", "rhsInt=2", "expFrac=3 1/2"), - Iteration("anticommutativity", "lhsInt=2", "rhsInt=7", "expFrac=2/7"), - Iteration("int/-int", "lhsInt=7", "rhsInt=-2", "expFrac=-3 1/2"), - Iteration("-int/int", "lhsInt=-7", "rhsInt=2", "expFrac=-3 1/2"), - Iteration("-int/-int", "lhsInt=-7", "rhsInt=-2", "expFrac=3 1/2") - ) + @Iteration("int/int", "lhsInt=7", "rhsInt=2", "expFrac=3 1/2") + @Iteration("anticommutativity", "lhsInt=2", "rhsInt=7", "expFrac=2/7") + @Iteration("int/-int", "lhsInt=7", "rhsInt=-2", "expFrac=-3 1/2") + @Iteration("-int/int", "lhsInt=-7", "rhsInt=2", "expFrac=-3 1/2") + @Iteration("-int/-int", "lhsInt=-7", "rhsInt=-2", "expFrac=3 1/2") fun testDiv_intAndInt_doesNotDivide_returnsFraction() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIntegerReal(rhsInt) @@ -1617,16 +1534,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity/identity", "lhsInt=1", "rhsFrac=1", "expFrac=1"), - Iteration("int/identity", "lhsInt=2", "rhsFrac=1", "expFrac=2"), - Iteration("int/fraction", "lhsInt=4", "rhsFrac=1/3", "expFrac=12"), - Iteration("int/wholeNumberFraction", "lhsInt=2", "rhsFrac=3/1", "expFrac=2/3"), - Iteration("anticommutativity", "lhsInt=3", "rhsFrac=2/1", "expFrac=1 1/2"), - Iteration("int/-fraction", "lhsInt=5", "rhsFrac=-2/3", "expFrac=-7 1/2"), - Iteration("-int/fraction", "lhsInt=-5", "rhsFrac=2/3", "expFrac=-7 1/2"), - Iteration("-int/-fraction", "lhsInt=-5", "rhsFrac=-2/3", "expFrac=7 1/2") - ) + @Iteration("identity/identity", "lhsInt=1", "rhsFrac=1", "expFrac=1") + @Iteration("int/identity", "lhsInt=2", "rhsFrac=1", "expFrac=2") + @Iteration("int/fraction", "lhsInt=4", "rhsFrac=1/3", "expFrac=12") + @Iteration("int/wholeNumberFraction", "lhsInt=2", "rhsFrac=3/1", "expFrac=2/3") + @Iteration("anticommutativity", "lhsInt=3", "rhsFrac=2/1", "expFrac=1 1/2") + @Iteration("int/-fraction", "lhsInt=5", "rhsFrac=-2/3", "expFrac=-7 1/2") + @Iteration("-int/fraction", "lhsInt=-5", "rhsFrac=2/3", "expFrac=-7 1/2") + @Iteration("-int/-fraction", "lhsInt=-5", "rhsFrac=-2/3", "expFrac=7 1/2") fun testDiv_intAndFraction_returnsFraction() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createRationalReal(rhsFrac) @@ -1638,16 +1553,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity/identity", "lhsInt=1", "rhsDouble=1.0", "expDouble=1.0"), - Iteration("int/identity", "lhsInt=2", "rhsDouble=1.0", "expDouble=2.0"), - Iteration("int/double", "lhsInt=2", "rhsDouble=3.14", "expDouble=0.636942675"), - Iteration("int/wholeNumberDouble", "lhsInt=2", "rhsDouble=3.0", "expDouble=0.666666667"), - Iteration("anticommutativity", "lhsInt=3", "rhsDouble=2.0", "expDouble=1.5"), - Iteration("int/-double", "lhsInt=2", "rhsDouble=-3.14", "expDouble=-0.636942675"), - Iteration("-int/double", "lhsInt=-2", "rhsDouble=3.14", "expDouble=-0.636942675"), - Iteration("-int/-double", "lhsInt=-2", "rhsDouble=-3.14", "expDouble=0.636942675") - ) + @Iteration("identity/identity", "lhsInt=1", "rhsDouble=1.0", "expDouble=1.0") + @Iteration("int/identity", "lhsInt=2", "rhsDouble=1.0", "expDouble=2.0") + @Iteration("int/double", "lhsInt=2", "rhsDouble=3.14", "expDouble=0.636942675") + @Iteration("int/wholeNumberDouble", "lhsInt=2", "rhsDouble=3.0", "expDouble=0.666666667") + @Iteration("anticommutativity", "lhsInt=3", "rhsDouble=2.0", "expDouble=1.5") + @Iteration("int/-double", "lhsInt=2", "rhsDouble=-3.14", "expDouble=-0.636942675") + @Iteration("-int/double", "lhsInt=-2", "rhsDouble=3.14", "expDouble=-0.636942675") + @Iteration("-int/-double", "lhsInt=-2", "rhsDouble=-3.14", "expDouble=0.636942675") fun testDiv_intAndDouble_returnsDouble() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIrrationalReal(rhsDouble) @@ -1658,16 +1571,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity/identity", "lhsFrac=1/1", "rhsInt=1", "expFrac=1"), - Iteration("fraction/identity", "lhsFrac=2/1", "rhsInt=1", "expFrac=2"), - Iteration("fraction/int", "lhsFrac=1/3", "rhsInt=2", "expFrac=1/6"), - Iteration("wholeNumberFraction/int", "lhsFrac=3/1", "rhsInt=2", "expFrac=1 1/2"), - Iteration("anticommutativity", "lhsFrac=2/1", "rhsInt=3", "expFrac=2/3"), - Iteration("fraction/-int", "lhsFrac=-1 1/3", "rhsInt=2", "expFrac=-2/3"), - Iteration("-fraction/int", "lhsFrac=1 1/3", "rhsInt=-2", "expFrac=-2/3"), - Iteration("-fraction/-int", "lhsFrac=-1 1/3", "rhsInt=-2", "expFrac=2/3") - ) + @Iteration("identity/identity", "lhsFrac=1/1", "rhsInt=1", "expFrac=1") + @Iteration("fraction/identity", "lhsFrac=2/1", "rhsInt=1", "expFrac=2") + @Iteration("fraction/int", "lhsFrac=1/3", "rhsInt=2", "expFrac=1/6") + @Iteration("wholeNumberFraction/int", "lhsFrac=3/1", "rhsInt=2", "expFrac=1 1/2") + @Iteration("anticommutativity", "lhsFrac=2/1", "rhsInt=3", "expFrac=2/3") + @Iteration("fraction/-int", "lhsFrac=-1 1/3", "rhsInt=2", "expFrac=-2/3") + @Iteration("-fraction/int", "lhsFrac=1 1/3", "rhsInt=-2", "expFrac=-2/3") + @Iteration("-fraction/-int", "lhsFrac=-1 1/3", "rhsInt=-2", "expFrac=2/3") fun testDiv_fractionAndInt_returnsFraction() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createIntegerReal(rhsInt) @@ -1679,15 +1590,13 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity/identity", "lhsFrac=1/1", "rhsFrac=1/1", "expFrac=1"), - Iteration("fraction/identity", "lhsFrac=3/2", "rhsFrac=1/1", "expFrac=1 1/2"), - Iteration("fraction/fraction", "lhsFrac=3/2", "rhsFrac=4/7", "expFrac=2 5/8"), - Iteration("anticommutativity", "lhsFrac=4/7", "rhsFrac=3/2", "expFrac=8/21"), - Iteration("fraction/-fraction", "lhsFrac=1 3/9", "rhsFrac=-8/11", "expFrac=-1 5/6"), - Iteration("-fraction/fraction", "lhsFrac=-1 3/9", "rhsFrac=8/11", "expFrac=-1 5/6"), - Iteration("-fraction/-fraction", "lhsFrac=-1 3/9", "rhsFrac=-8/11", "expFrac=1 5/6") - ) + @Iteration("identity/identity", "lhsFrac=1/1", "rhsFrac=1/1", "expFrac=1") + @Iteration("fraction/identity", "lhsFrac=3/2", "rhsFrac=1/1", "expFrac=1 1/2") + @Iteration("fraction/fraction", "lhsFrac=3/2", "rhsFrac=4/7", "expFrac=2 5/8") + @Iteration("anticommutativity", "lhsFrac=4/7", "rhsFrac=3/2", "expFrac=8/21") + @Iteration("fraction/-fraction", "lhsFrac=1 3/9", "rhsFrac=-8/11", "expFrac=-1 5/6") + @Iteration("-fraction/fraction", "lhsFrac=-1 3/9", "rhsFrac=8/11", "expFrac=-1 5/6") + @Iteration("-fraction/-fraction", "lhsFrac=-1 3/9", "rhsFrac=-8/11", "expFrac=1 5/6") fun testDiv_fractionAndFraction_returnsFraction() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createRationalReal(rhsFrac) @@ -1699,16 +1608,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity/identity", "lhsFrac=1/1", "rhsDouble=1.0", "expDouble=1.0"), - Iteration("fraction/identity", "lhsFrac=3/2", "rhsDouble=1.0", "expDouble=1.5"), - Iteration("fraction/double", "lhsFrac=3/2", "rhsDouble=3.14", "expDouble=0.477707006"), - Iteration("wholeNumberFraction/double", "lhsFrac=3/1", "rhsDouble=2.0", "expDouble=1.5"), - Iteration("anticommutativity", "lhsFrac=2/1", "rhsDouble=3.0", "expDouble=0.666666667"), - Iteration("fraction/-double", "lhsFrac=1 3/2", "rhsDouble=-3.14", "expDouble=-0.796178344"), - Iteration("-fraction/double", "lhsFrac=-1 3/2", "rhsDouble=3.14", "expDouble=-0.796178344"), - Iteration("-fraction/-double", "lhsFrac=-1 3/2", "rhsDouble=-3.14", "expDouble=0.796178344") - ) + @Iteration("identity/identity", "lhsFrac=1/1", "rhsDouble=1.0", "expDouble=1.0") + @Iteration("fraction/identity", "lhsFrac=3/2", "rhsDouble=1.0", "expDouble=1.5") + @Iteration("fraction/double", "lhsFrac=3/2", "rhsDouble=3.14", "expDouble=0.477707006") + @Iteration("wholeNumberFraction/double", "lhsFrac=3/1", "rhsDouble=2.0", "expDouble=1.5") + @Iteration("anticommutativity", "lhsFrac=2/1", "rhsDouble=3.0", "expDouble=0.666666667") + @Iteration("fraction/-double", "lhsFrac=1 3/2", "rhsDouble=-3.14", "expDouble=-0.796178344") + @Iteration("-fraction/double", "lhsFrac=-1 3/2", "rhsDouble=3.14", "expDouble=-0.796178344") + @Iteration("-fraction/-double", "lhsFrac=-1 3/2", "rhsDouble=-3.14", "expDouble=0.796178344") fun testDiv_fractionAndDouble_returnsDouble() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createIrrationalReal(rhsDouble) @@ -1719,16 +1626,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity/identity", "lhsDouble=1.0", "rhsInt=1", "expDouble=1.0"), - Iteration("double/identity", "lhsDouble=2.0", "rhsInt=1", "expDouble=2.0"), - Iteration("double/int", "lhsDouble=3.14", "rhsInt=2", "expDouble=1.57"), - Iteration("wholeNumberDouble/int", "lhsDouble=3.0", "rhsInt=2", "expDouble=1.5"), - Iteration("anticommutativity", "lhsDouble=2.0", "rhsInt=3", "expDouble=0.666666667"), - Iteration("double/-int", "lhsDouble=3.14", "rhsInt=-2", "expDouble=-1.57"), - Iteration("-double/int", "lhsDouble=-3.14", "rhsInt=2", "expDouble=-1.57"), - Iteration("-double/-int", "lhsDouble=-3.14", "rhsInt=-2", "expDouble=1.57") - ) + @Iteration("identity/identity", "lhsDouble=1.0", "rhsInt=1", "expDouble=1.0") + @Iteration("double/identity", "lhsDouble=2.0", "rhsInt=1", "expDouble=2.0") + @Iteration("double/int", "lhsDouble=3.14", "rhsInt=2", "expDouble=1.57") + @Iteration("wholeNumberDouble/int", "lhsDouble=3.0", "rhsInt=2", "expDouble=1.5") + @Iteration("anticommutativity", "lhsDouble=2.0", "rhsInt=3", "expDouble=0.666666667") + @Iteration("double/-int", "lhsDouble=3.14", "rhsInt=-2", "expDouble=-1.57") + @Iteration("-double/int", "lhsDouble=-3.14", "rhsInt=2", "expDouble=-1.57") + @Iteration("-double/-int", "lhsDouble=-3.14", "rhsInt=-2", "expDouble=1.57") fun testDiv_doubleAndInt_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createIntegerReal(rhsInt) @@ -1739,16 +1644,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity/identity", "lhsDouble=1.0", "rhsFrac=1/1", "expDouble=1.0"), - Iteration("double/identity", "lhsDouble=2.0", "rhsFrac=1/1", "expDouble=2.0"), - Iteration("double/fraction", "lhsDouble=3.14", "rhsFrac=3/2", "expDouble=2.093333333"), - Iteration("double/wholeNumberFraction", "lhsDouble=2.0", "rhsFrac=3/1", "expDouble=0.66666667"), - Iteration("anticommutativity", "lhsDouble=3.0", "rhsFrac=2/1", "expDouble=1.5"), - Iteration("double/-fraction", "lhsDouble=3.14", "rhsFrac=-1 3/2", "expDouble=-1.256"), - Iteration("-double/fraction", "lhsDouble=-3.14", "rhsFrac=1 3/2", "expDouble=-1.256"), - Iteration("-double/-fraction", "lhsDouble=-3.14", "rhsFrac=-1 3/2", "expDouble=1.256") - ) + @Iteration("identity/identity", "lhsDouble=1.0", "rhsFrac=1/1", "expDouble=1.0") + @Iteration("double/identity", "lhsDouble=2.0", "rhsFrac=1/1", "expDouble=2.0") + @Iteration("double/fraction", "lhsDouble=3.14", "rhsFrac=3/2", "expDouble=2.093333333") + @Iteration("double/wholeNumberFraction", "lhsDouble=2.0", "rhsFrac=3/1", "expDouble=0.66666667") + @Iteration("anticommutativity", "lhsDouble=3.0", "rhsFrac=2/1", "expDouble=1.5") + @Iteration("double/-fraction", "lhsDouble=3.14", "rhsFrac=-1 3/2", "expDouble=-1.256") + @Iteration("-double/fraction", "lhsDouble=-3.14", "rhsFrac=1 3/2", "expDouble=-1.256") + @Iteration("-double/-fraction", "lhsDouble=-3.14", "rhsFrac=-1 3/2", "expDouble=1.256") fun testDiv_doubleAndFraction_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createRationalReal(rhsFrac) @@ -1759,15 +1662,13 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("identity/identity", "lhsDouble=1.0", "rhsDouble=1.0", "expDouble=1.0"), - Iteration("double/identity", "lhsDouble=2.0", "rhsDouble=1.0", "expDouble=2.0"), - Iteration("double/double", "lhsDouble=3.14", "rhsDouble=2.7", "expDouble=1.162962963"), - Iteration("anticommutativity", "lhsDouble=2.7", "rhsDouble=3.14", "expDouble=0.859872611"), - Iteration("double/-double", "lhsDouble=3.14", "rhsDouble=-2.7", "expDouble=-1.162962963"), - Iteration("-double/double", "lhsDouble=-3.14", "rhsDouble=2.7", "expDouble=-1.162962963"), - Iteration("-double/-double", "lhsDouble=-3.14", "rhsDouble=-2.7", "expDouble=1.162962963") - ) + @Iteration("identity/identity", "lhsDouble=1.0", "rhsDouble=1.0", "expDouble=1.0") + @Iteration("double/identity", "lhsDouble=2.0", "rhsDouble=1.0", "expDouble=2.0") + @Iteration("double/double", "lhsDouble=3.14", "rhsDouble=2.7", "expDouble=1.162962963") + @Iteration("anticommutativity", "lhsDouble=2.7", "rhsDouble=3.14", "expDouble=0.859872611") + @Iteration("double/-double", "lhsDouble=3.14", "rhsDouble=-2.7", "expDouble=-1.162962963") + @Iteration("-double/double", "lhsDouble=-3.14", "rhsDouble=2.7", "expDouble=-1.162962963") + @Iteration("-double/-double", "lhsDouble=-3.14", "rhsDouble=-2.7", "expDouble=1.162962963") fun testDiv_doubleAndDouble_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createIrrationalReal(rhsDouble) @@ -1862,17 +1763,15 @@ class RealExtensionsTest { // Exponentiation tests. @Test - @RunParameterized( - Iteration("0^0", "lhsInt=0", "rhsInt=0", "expInt=1"), - Iteration("identity^0", "lhsInt=1", "rhsInt=0", "expInt=1"), - Iteration("identity^identity", "lhsInt=1", "rhsInt=1", "expInt=1"), - Iteration("int^0", "lhsInt=2", "rhsInt=0", "expInt=1"), - Iteration("int^identity", "lhsInt=2", "rhsInt=1", "expInt=2"), - Iteration("int^int", "lhsInt=2", "rhsInt=3", "expInt=8"), - Iteration("noncommutativity", "lhsInt=3", "rhsInt=2", "expInt=9"), - Iteration("-int^even int", "lhsInt=-2", "rhsInt=4", "expInt=16"), - Iteration("-int^odd int", "lhsInt=-2", "rhsInt=3", "expInt=-8") - ) + @Iteration("0^0", "lhsInt=0", "rhsInt=0", "expInt=1") + @Iteration("identity^0", "lhsInt=1", "rhsInt=0", "expInt=1") + @Iteration("identity^identity", "lhsInt=1", "rhsInt=1", "expInt=1") + @Iteration("int^0", "lhsInt=2", "rhsInt=0", "expInt=1") + @Iteration("int^identity", "lhsInt=2", "rhsInt=1", "expInt=2") + @Iteration("int^int", "lhsInt=2", "rhsInt=3", "expInt=8") + @Iteration("noncommutativity", "lhsInt=3", "rhsInt=2", "expInt=9") + @Iteration("-int^even int", "lhsInt=-2", "rhsInt=4", "expInt=16") + @Iteration("-int^odd int", "lhsInt=-2", "rhsInt=3", "expInt=-8") fun testPow_intAndInt_positivePower_returnsInt() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIntegerReal(rhsInt) @@ -1884,11 +1783,9 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("int^-int", "lhsInt=2", "rhsInt=-3", "expFrac=1/8"), - Iteration("-int^-even int", "lhsInt=-2", "rhsInt=-4", "expFrac=1/16"), - Iteration("-int^-odd int", "lhsInt=-2", "rhsInt=-3", "expFrac=-1/8") - ) + @Iteration("int^-int", "lhsInt=2", "rhsInt=-3", "expFrac=1/8") + @Iteration("-int^-even int", "lhsInt=-2", "rhsInt=-4", "expFrac=1/16") + @Iteration("-int^-odd int", "lhsInt=-2", "rhsInt=-3", "expFrac=-1/8") fun testPow_intAndInt_negativePower_returnsFraction() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIntegerReal(rhsInt) @@ -1901,21 +1798,19 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0^0", "lhsInt=0", "rhsFrac=0/1", "expFrac=1"), - Iteration("identity^0", "lhsInt=1", "rhsFrac=0/1", "expFrac=1"), - Iteration("identity^identity", "lhsInt=1", "rhsFrac=1", "expFrac=1"), - Iteration("int^0", "lhsInt=2", "rhsFrac=0/1", "expFrac=1"), - Iteration("int^identity", "lhsInt=2", "rhsFrac=1", "expFrac=2"), - Iteration("int^fraction", "lhsInt=16", "rhsFrac=3/2", "expFrac=64"), - Iteration("int^wholeNumberFraction", "lhsInt=2", "rhsFrac=3/1", "expFrac=8"), - Iteration("noncommutativity", "lhsInt=3", "rhsFrac=2/1", "expFrac=9"), - Iteration("int^odd fraction", "lhsInt=8", "rhsFrac=5/3", "expFrac=32"), - Iteration("int^-fraction", "lhsInt=8", "rhsFrac=-4/2", "expFrac=1/64"), - Iteration("-int^odd fraction", "lhsInt=-8", "rhsFrac=5/3", "expFrac=-32"), - Iteration("-int^-fraction", "lhsInt=-4", "rhsFrac=-4/2", "expFrac=1/16"), - Iteration("-int^-odd fraction", "lhsInt=-8", "rhsFrac=-5/3", "expFrac=-1/32") - ) + @Iteration("0^0", "lhsInt=0", "rhsFrac=0/1", "expFrac=1") + @Iteration("identity^0", "lhsInt=1", "rhsFrac=0/1", "expFrac=1") + @Iteration("identity^identity", "lhsInt=1", "rhsFrac=1", "expFrac=1") + @Iteration("int^0", "lhsInt=2", "rhsFrac=0/1", "expFrac=1") + @Iteration("int^identity", "lhsInt=2", "rhsFrac=1", "expFrac=2") + @Iteration("int^fraction", "lhsInt=16", "rhsFrac=3/2", "expFrac=64") + @Iteration("int^wholeNumberFraction", "lhsInt=2", "rhsFrac=3/1", "expFrac=8") + @Iteration("noncommutativity", "lhsInt=3", "rhsFrac=2/1", "expFrac=9") + @Iteration("int^odd fraction", "lhsInt=8", "rhsFrac=5/3", "expFrac=32") + @Iteration("int^-fraction", "lhsInt=8", "rhsFrac=-4/2", "expFrac=1/64") + @Iteration("-int^odd fraction", "lhsInt=-8", "rhsFrac=5/3", "expFrac=-32") + @Iteration("-int^-fraction", "lhsInt=-4", "rhsFrac=-4/2", "expFrac=1/16") + @Iteration("-int^-odd fraction", "lhsInt=-8", "rhsFrac=-5/3", "expFrac=-1/32") fun testPow_intAndFraction_denominatorCanRootInt_returnsFraction() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createRationalReal(rhsFrac) @@ -1927,12 +1822,10 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("int^fraction", "lhsInt=3", "rhsFrac=2/3", "expDouble=2.080083823"), - Iteration("-int^fraction", "lhsInt=-4", "rhsFrac=2/3", "expDouble=2.5198421"), - Iteration("int^-fraction", "lhsInt=2", "rhsFrac=-2/3", "expDouble=0.629960525"), - Iteration("-int^-fraction", "lhsInt=-4", "rhsFrac=-2/3", "expDouble=0.396850263") - ) + @Iteration("int^fraction", "lhsInt=3", "rhsFrac=2/3", "expDouble=2.080083823") + @Iteration("-int^fraction", "lhsInt=-4", "rhsFrac=2/3", "expDouble=2.5198421") + @Iteration("int^-fraction", "lhsInt=2", "rhsFrac=-2/3", "expDouble=0.629960525") + @Iteration("-int^-fraction", "lhsInt=-4", "rhsFrac=-2/3", "expDouble=0.396850263") fun testPow_intAndFraction_denominatorCannotRootInt_returnsDouble() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createRationalReal(rhsFrac) @@ -1943,17 +1836,15 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0^0", "lhsInt=0", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("identity^0", "lhsInt=1", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("identity^identity", "lhsInt=1", "rhsDouble=1.0", "expDouble=1.0"), - Iteration("int^0", "lhsInt=2", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("int^identity", "lhsInt=2", "rhsDouble=1.0", "expDouble=2.0"), - Iteration("int^double", "lhsInt=2", "rhsDouble=3.14", "expDouble=8.815240927"), - Iteration("int^wholeNumberDouble", "lhsInt=2", "rhsDouble=3.0", "expDouble=8.0"), - Iteration("noncommutativity", "lhsInt=3", "rhsDouble=2.0", "expDouble=9.0"), - Iteration("int^-double", "lhsInt=2", "rhsDouble=-3.14", "expDouble=0.113439894") - ) + @Iteration("0^0", "lhsInt=0", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("identity^0", "lhsInt=1", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("identity^identity", "lhsInt=1", "rhsDouble=1.0", "expDouble=1.0") + @Iteration("int^0", "lhsInt=2", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("int^identity", "lhsInt=2", "rhsDouble=1.0", "expDouble=2.0") + @Iteration("int^double", "lhsInt=2", "rhsDouble=3.14", "expDouble=8.815240927") + @Iteration("int^wholeNumberDouble", "lhsInt=2", "rhsDouble=3.0", "expDouble=8.0") + @Iteration("noncommutativity", "lhsInt=3", "rhsDouble=2.0", "expDouble=9.0") + @Iteration("int^-double", "lhsInt=2", "rhsDouble=-3.14", "expDouble=0.113439894") fun testPow_intAndDouble_returnsDouble() { val lhsReal = createIntegerReal(lhsInt) val rhsReal = createIrrationalReal(rhsDouble) @@ -1964,19 +1855,17 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0^0", "lhsFrac=0", "rhsInt=0", "expFrac=1"), - Iteration("identity^0", "lhsFrac=1", "rhsInt=0", "expFrac=1"), - Iteration("identity^identity", "lhsFrac=1", "rhsInt=1", "expFrac=1"), - Iteration("fraction^0", "lhsFrac=1/3", "rhsInt=0", "expFrac=1"), - Iteration("fraction^identity", "lhsFrac=1/3", "rhsInt=1", "expFrac=1/3"), - Iteration("fraction^int", "lhsFrac=2/3", "rhsInt=3", "expFrac=8/27"), - Iteration("wholeNumberFraction^int", "lhsFrac=3", "rhsInt=2", "expFrac=9"), - Iteration("noncommutativity", "lhsFrac=2", "rhsInt=3", "expFrac=8"), - Iteration("fraction^-int", "lhsFrac=4/3", "rhsInt=-2", "expFrac=9/16"), - Iteration("-fraction^int", "lhsFrac=-4/3", "rhsInt=2", "expFrac=1 7/9"), - Iteration("-fraction^-int", "lhsFrac=-4/3", "rhsInt=-2", "expFrac=9/16") - ) + @Iteration("0^0", "lhsFrac=0", "rhsInt=0", "expFrac=1") + @Iteration("identity^0", "lhsFrac=1", "rhsInt=0", "expFrac=1") + @Iteration("identity^identity", "lhsFrac=1", "rhsInt=1", "expFrac=1") + @Iteration("fraction^0", "lhsFrac=1/3", "rhsInt=0", "expFrac=1") + @Iteration("fraction^identity", "lhsFrac=1/3", "rhsInt=1", "expFrac=1/3") + @Iteration("fraction^int", "lhsFrac=2/3", "rhsInt=3", "expFrac=8/27") + @Iteration("wholeNumberFraction^int", "lhsFrac=3", "rhsInt=2", "expFrac=9") + @Iteration("noncommutativity", "lhsFrac=2", "rhsInt=3", "expFrac=8") + @Iteration("fraction^-int", "lhsFrac=4/3", "rhsInt=-2", "expFrac=9/16") + @Iteration("-fraction^int", "lhsFrac=-4/3", "rhsInt=2", "expFrac=1 7/9") + @Iteration("-fraction^-int", "lhsFrac=-4/3", "rhsInt=-2", "expFrac=9/16") fun testPow_fractionAndInt_returnsFraction() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createIntegerReal(rhsInt) @@ -1988,17 +1877,15 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0^0", "lhsFrac=0", "rhsFrac=0", "expFrac=1"), - Iteration("identity^0", "lhsFrac=1", "rhsFrac=0", "expFrac=1"), - Iteration("identity^identity", "lhsFrac=1", "rhsFrac=1", "expFrac=1"), - Iteration("fraction^0", "lhsFrac=3/2", "rhsFrac=0", "expFrac=1"), - Iteration("fraction^identity", "lhsFrac=3/2", "rhsFrac=1", "expFrac=1 1/2"), - Iteration("fraction^fraction", "lhsFrac=32/243", "rhsFrac=3/5", "expFrac=8/27"), - Iteration("fraction^wholeNumberFraction", "lhsFrac=3", "rhsFrac=2", "expFrac=9"), - Iteration("noncommutativity", "lhsFrac=2", "rhsFrac=3", "expFrac=8"), - Iteration("fraction^-fraction", "lhsFrac=32/243", "rhsFrac=-3/5", "expFrac=3 3/8") - ) + @Iteration("0^0", "lhsFrac=0", "rhsFrac=0", "expFrac=1") + @Iteration("identity^0", "lhsFrac=1", "rhsFrac=0", "expFrac=1") + @Iteration("identity^identity", "lhsFrac=1", "rhsFrac=1", "expFrac=1") + @Iteration("fraction^0", "lhsFrac=3/2", "rhsFrac=0", "expFrac=1") + @Iteration("fraction^identity", "lhsFrac=3/2", "rhsFrac=1", "expFrac=1 1/2") + @Iteration("fraction^fraction", "lhsFrac=32/243", "rhsFrac=3/5", "expFrac=8/27") + @Iteration("fraction^wholeNumberFraction", "lhsFrac=3", "rhsFrac=2", "expFrac=9") + @Iteration("noncommutativity", "lhsFrac=2", "rhsFrac=3", "expFrac=8") + @Iteration("fraction^-fraction", "lhsFrac=32/243", "rhsFrac=-3/5", "expFrac=3 3/8") fun testPow_fractionAndFraction_denominatorCanRootFraction_returnsFraction() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createRationalReal(rhsFrac) @@ -2010,11 +1897,9 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("fraction^fraction", "lhsFrac=3/2", "rhsFrac=2/3", "expDouble=1.310370697"), - Iteration("noncommutativity", "lhsFrac=2/3", "rhsFrac=3/2", "expDouble=0.544331054"), - Iteration("fraction^-fraction", "lhsFrac=3/2", "rhsFrac=-2/3", "expDouble=0.763142828") - ) + @Iteration("fraction^fraction", "lhsFrac=3/2", "rhsFrac=2/3", "expDouble=1.310370697") + @Iteration("noncommutativity", "lhsFrac=2/3", "rhsFrac=3/2", "expDouble=0.544331054") + @Iteration("fraction^-fraction", "lhsFrac=3/2", "rhsFrac=-2/3", "expDouble=0.763142828") fun testPow_fractionAndFraction_denominatorCannotRootFraction_returnsDouble() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createRationalReal(rhsFrac) @@ -2025,17 +1910,15 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0^0", "lhsFrac=0", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("identity^0", "lhsFrac=1", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("identity^identity", "lhsFrac=1", "rhsDouble=1.0", "expDouble=1.0"), - Iteration("fraction^0", "lhsFrac=3/2", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("fraction^identity", "lhsFrac=3/2", "rhsDouble=1.0", "expDouble=1.5"), - Iteration("fraction^double", "lhsFrac=3/2", "rhsDouble=3.14", "expDouble=3.572124224"), - Iteration("wholeNumberFraction^double", "lhsFrac=3", "rhsDouble=2.0", "expDouble=9.0"), - Iteration("noncommutativity", "lhsFrac=2", "rhsDouble=3.0", "expDouble=8.0"), - Iteration("fraction^-double", "lhsFrac=1 3/2", "rhsDouble=-3.14", "expDouble=0.056294812") - ) + @Iteration("0^0", "lhsFrac=0", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("identity^0", "lhsFrac=1", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("identity^identity", "lhsFrac=1", "rhsDouble=1.0", "expDouble=1.0") + @Iteration("fraction^0", "lhsFrac=3/2", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("fraction^identity", "lhsFrac=3/2", "rhsDouble=1.0", "expDouble=1.5") + @Iteration("fraction^double", "lhsFrac=3/2", "rhsDouble=3.14", "expDouble=3.572124224") + @Iteration("wholeNumberFraction^double", "lhsFrac=3", "rhsDouble=2.0", "expDouble=9.0") + @Iteration("noncommutativity", "lhsFrac=2", "rhsDouble=3.0", "expDouble=8.0") + @Iteration("fraction^-double", "lhsFrac=1 3/2", "rhsDouble=-3.14", "expDouble=0.056294812") fun testPow_fractionAndDouble_returnsDouble() { val lhsReal = createRationalReal(lhsFrac) val rhsReal = createIrrationalReal(rhsDouble) @@ -2046,19 +1929,17 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0^0", "lhsDouble=0.0", "rhsInt=0", "expDouble=1.0"), - Iteration("identity^0", "lhsDouble=1.0", "rhsInt=0", "expDouble=1.0"), - Iteration("identity^identity", "lhsDouble=1.0", "rhsInt=1", "expDouble=1.0"), - Iteration("double^0", "lhsDouble=3.14", "rhsInt=0", "expDouble=1.0"), - Iteration("double^identity", "lhsDouble=3.14", "rhsInt=1", "expDouble=3.14"), - Iteration("double^int", "lhsDouble=3.14", "rhsInt=2", "expDouble=9.8596"), - Iteration("wholeNumberDouble^int", "lhsDouble=3.0", "rhsInt=2", "expDouble=9.0"), - Iteration("noncommutativity", "lhsDouble=2.0", "rhsInt=3", "expDouble=8.0"), - Iteration("double^-int", "lhsDouble=3.14", "rhsInt=-3", "expDouble=0.032300635"), - Iteration("-double^int", "lhsDouble=-3.14", "rhsInt=3", "expDouble=-30.959144"), - Iteration("-double^-int", "lhsDouble=-3.14", "rhsInt=-3", "expDouble=-0.032300635") - ) + @Iteration("0^0", "lhsDouble=0.0", "rhsInt=0", "expDouble=1.0") + @Iteration("identity^0", "lhsDouble=1.0", "rhsInt=0", "expDouble=1.0") + @Iteration("identity^identity", "lhsDouble=1.0", "rhsInt=1", "expDouble=1.0") + @Iteration("double^0", "lhsDouble=3.14", "rhsInt=0", "expDouble=1.0") + @Iteration("double^identity", "lhsDouble=3.14", "rhsInt=1", "expDouble=3.14") + @Iteration("double^int", "lhsDouble=3.14", "rhsInt=2", "expDouble=9.8596") + @Iteration("wholeNumberDouble^int", "lhsDouble=3.0", "rhsInt=2", "expDouble=9.0") + @Iteration("noncommutativity", "lhsDouble=2.0", "rhsInt=3", "expDouble=8.0") + @Iteration("double^-int", "lhsDouble=3.14", "rhsInt=-3", "expDouble=0.032300635") + @Iteration("-double^int", "lhsDouble=-3.14", "rhsInt=3", "expDouble=-30.959144") + @Iteration("-double^-int", "lhsDouble=-3.14", "rhsInt=-3", "expDouble=-0.032300635") fun testPow_doubleAndInt_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createIntegerReal(rhsInt) @@ -2069,17 +1950,15 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0^0", "lhsDouble=0.0", "rhsFrac=0/1", "expDouble=1.0"), - Iteration("identity^0", "lhsDouble=1.0", "rhsFrac=0/1", "expDouble=1.0"), - Iteration("identity^identity", "lhsDouble=1.0", "rhsFrac=1", "expDouble=1.0"), - Iteration("double^0", "lhsDouble=3.14", "rhsFrac=0/1", "expDouble=1.0"), - Iteration("double^identity", "lhsDouble=3.14", "rhsFrac=1", "expDouble=3.14"), - Iteration("double^fraction", "lhsDouble=3.14", "rhsFrac=3/2", "expDouble=5.564094176"), - Iteration("double^wholeNumberFraction", "lhsDouble=2.0", "rhsFrac=3/1", "expDouble=8.0"), - Iteration("noncommutativity", "lhsDouble=3.0", "rhsFrac=2/1", "expDouble=9.0"), - Iteration("double^-fraction", "lhsDouble=3.14", "rhsFrac=-3/2", "expDouble=0.179723773") - ) + @Iteration("0^0", "lhsDouble=0.0", "rhsFrac=0/1", "expDouble=1.0") + @Iteration("identity^0", "lhsDouble=1.0", "rhsFrac=0/1", "expDouble=1.0") + @Iteration("identity^identity", "lhsDouble=1.0", "rhsFrac=1", "expDouble=1.0") + @Iteration("double^0", "lhsDouble=3.14", "rhsFrac=0/1", "expDouble=1.0") + @Iteration("double^identity", "lhsDouble=3.14", "rhsFrac=1", "expDouble=3.14") + @Iteration("double^fraction", "lhsDouble=3.14", "rhsFrac=3/2", "expDouble=5.564094176") + @Iteration("double^wholeNumberFraction", "lhsDouble=2.0", "rhsFrac=3/1", "expDouble=8.0") + @Iteration("noncommutativity", "lhsDouble=3.0", "rhsFrac=2/1", "expDouble=9.0") + @Iteration("double^-fraction", "lhsDouble=3.14", "rhsFrac=-3/2", "expDouble=0.179723773") fun testPow_doubleAndFraction_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createRationalReal(rhsFrac) @@ -2090,16 +1969,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0^0", "lhsDouble=0.0", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("identity^0", "lhsDouble=1.0", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("identity^identity", "lhsDouble=1.0", "rhsDouble=1.0", "expDouble=1.0"), - Iteration("double^0", "lhsDouble=3.14", "rhsDouble=0.0", "expDouble=1.0"), - Iteration("double^identity", "lhsDouble=3.14", "rhsDouble=1.0", "expDouble=3.14"), - Iteration("double^double", "lhsDouble=3.14", "rhsDouble=2.7", "expDouble=21.963929943"), - Iteration("noncommutativity", "lhsDouble=2.7", "rhsDouble=3.14", "expDouble=22.619459311"), - Iteration("double^-double", "lhsDouble=3.14", "rhsDouble=-2.7", "expDouble=0.045529193") - ) + @Iteration("0^0", "lhsDouble=0.0", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("identity^0", "lhsDouble=1.0", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("identity^identity", "lhsDouble=1.0", "rhsDouble=1.0", "expDouble=1.0") + @Iteration("double^0", "lhsDouble=3.14", "rhsDouble=0.0", "expDouble=1.0") + @Iteration("double^identity", "lhsDouble=3.14", "rhsDouble=1.0", "expDouble=3.14") + @Iteration("double^double", "lhsDouble=3.14", "rhsDouble=2.7", "expDouble=21.963929943") + @Iteration("noncommutativity", "lhsDouble=2.7", "rhsDouble=3.14", "expDouble=22.619459311") + @Iteration("double^-double", "lhsDouble=3.14", "rhsDouble=-2.7", "expDouble=0.045529193") fun testPow_doubleAndDouble_returnsDouble() { val lhsReal = createIrrationalReal(lhsDouble) val rhsReal = createIrrationalReal(rhsDouble) @@ -2346,17 +2223,15 @@ class RealExtensionsTest { */ @Test - @RunParameterized( - Iteration("0==0", "lhsInt=0", "rhsInt=0", "expInt=0"), - Iteration("-2<0", "lhsInt=-2", "rhsInt=0", "expInt=-1"), - Iteration("-5<-2", "lhsInt=-5", "rhsInt=-2", "expInt=-1"), - Iteration("-2>-5", "lhsInt=-2", "rhsInt=-5", "expInt=1"), - Iteration("2>0", "lhsInt=2", "rhsInt=0", "expInt=1"), - Iteration("5>2", "lhsInt=5", "rhsInt=2", "expInt=1"), - Iteration("2<5", "lhsInt=2", "rhsInt=5", "expInt=-1"), - Iteration("-2<5", "lhsInt=-2", "rhsInt=5", "expInt=-1"), - Iteration("5>-2", "lhsInt=5", "rhsInt=-2", "expInt=1") - ) + @Iteration("0==0", "lhsInt=0", "rhsInt=0", "expInt=0") + @Iteration("-2<0", "lhsInt=-2", "rhsInt=0", "expInt=-1") + @Iteration("-5<-2", "lhsInt=-5", "rhsInt=-2", "expInt=-1") + @Iteration("-2>-5", "lhsInt=-2", "rhsInt=-5", "expInt=1") + @Iteration("2>0", "lhsInt=2", "rhsInt=0", "expInt=1") + @Iteration("5>2", "lhsInt=5", "rhsInt=2", "expInt=1") + @Iteration("2<5", "lhsInt=2", "rhsInt=5", "expInt=-1") + @Iteration("-2<5", "lhsInt=-2", "rhsInt=5", "expInt=-1") + @Iteration("5>-2", "lhsInt=5", "rhsInt=-2", "expInt=1") fun testComparator_intAndInt_returnsCorrectComparisonInt() { val lhsValue = createIntegerReal(lhsInt) val rhsValue = createIntegerReal(rhsInt) @@ -2367,23 +2242,21 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0", "lhsInt=0", "rhsFrac=0", "expInt=0"), - Iteration("-2<0", "lhsInt=-2", "rhsFrac=0", "expInt=-1"), - Iteration("-5<-2", "lhsInt=-5", "rhsFrac=-2", "expInt=-1"), - Iteration("-5<-1/2", "lhsInt=-5", "rhsFrac=-1/2", "expInt=-1"), - Iteration("-2>-5", "lhsInt=-2", "rhsFrac=-5", "expInt=1"), - Iteration("-1>-3/2", "lhsInt=-1", "rhsFrac=-3/2", "expInt=1"), - Iteration("2>0", "lhsInt=2", "rhsFrac=0", "expInt=1"), - Iteration("5>2", "lhsInt=5", "rhsFrac=2", "expInt=1"), - Iteration("2<5", "lhsInt=2", "rhsFrac=5", "expInt=-1"), - Iteration("2<7/2", "lhsInt=2", "rhsFrac=7/2", "expInt=-1"), - Iteration("5>3/2", "lhsInt=5", "rhsFrac=3/2", "expInt=1"), - Iteration("-2<5", "lhsInt=-2", "rhsFrac=5", "expInt=-1"), - Iteration("-2<3/2", "lhsInt=-2", "rhsFrac=3/2", "expInt=-1"), - Iteration("5>-2", "lhsInt=5", "rhsFrac=-2", "expInt=1"), - Iteration("5>-3/2", "lhsInt=5", "rhsFrac=-3/2", "expInt=1") - ) + @Iteration("0==0", "lhsInt=0", "rhsFrac=0", "expInt=0") + @Iteration("-2<0", "lhsInt=-2", "rhsFrac=0", "expInt=-1") + @Iteration("-5<-2", "lhsInt=-5", "rhsFrac=-2", "expInt=-1") + @Iteration("-5<-1/2", "lhsInt=-5", "rhsFrac=-1/2", "expInt=-1") + @Iteration("-2>-5", "lhsInt=-2", "rhsFrac=-5", "expInt=1") + @Iteration("-1>-3/2", "lhsInt=-1", "rhsFrac=-3/2", "expInt=1") + @Iteration("2>0", "lhsInt=2", "rhsFrac=0", "expInt=1") + @Iteration("5>2", "lhsInt=5", "rhsFrac=2", "expInt=1") + @Iteration("2<5", "lhsInt=2", "rhsFrac=5", "expInt=-1") + @Iteration("2<7/2", "lhsInt=2", "rhsFrac=7/2", "expInt=-1") + @Iteration("5>3/2", "lhsInt=5", "rhsFrac=3/2", "expInt=1") + @Iteration("-2<5", "lhsInt=-2", "rhsFrac=5", "expInt=-1") + @Iteration("-2<3/2", "lhsInt=-2", "rhsFrac=3/2", "expInt=-1") + @Iteration("5>-2", "lhsInt=5", "rhsFrac=-2", "expInt=1") + @Iteration("5>-3/2", "lhsInt=5", "rhsFrac=-3/2", "expInt=1") fun testComparator_intAndFraction_returnsCorrectComparisonInt() { val lhsValue = createIntegerReal(lhsInt) val rhsValue = createRationalReal(rhsFrac) @@ -2394,17 +2267,15 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0", "lhsInt=0", "rhsDouble=0.0", "expInt=0"), - Iteration("-2<0", "lhsInt=-2", "rhsDouble=0.0", "expInt=-1"), - Iteration("-5<-3.14", "lhsInt=-5", "rhsDouble=-3.14", "expInt=-1"), - Iteration("-2>-6.28", "lhsInt=-2", "rhsDouble=-6.28", "expInt=1"), - Iteration("2>0", "lhsInt=2", "rhsDouble=0.0", "expInt=1"), - Iteration("5>3.14", "lhsInt=5", "rhsDouble=3.14", "expInt=1"), - Iteration("2<6.28", "lhsInt=2", "rhsDouble=6.28", "expInt=-1"), - Iteration("-2<3.14", "lhsInt=-2", "rhsDouble=3.14", "expInt=-1"), - Iteration("2>-3.14", "lhsInt=2", "rhsDouble=-3.14", "expInt=1") - ) + @Iteration("0==0", "lhsInt=0", "rhsDouble=0.0", "expInt=0") + @Iteration("-2<0", "lhsInt=-2", "rhsDouble=0.0", "expInt=-1") + @Iteration("-5<-3.14", "lhsInt=-5", "rhsDouble=-3.14", "expInt=-1") + @Iteration("-2>-6.28", "lhsInt=-2", "rhsDouble=-6.28", "expInt=1") + @Iteration("2>0", "lhsInt=2", "rhsDouble=0.0", "expInt=1") + @Iteration("5>3.14", "lhsInt=5", "rhsDouble=3.14", "expInt=1") + @Iteration("2<6.28", "lhsInt=2", "rhsDouble=6.28", "expInt=-1") + @Iteration("-2<3.14", "lhsInt=-2", "rhsDouble=3.14", "expInt=-1") + @Iteration("2>-3.14", "lhsInt=2", "rhsDouble=-3.14", "expInt=1") fun testComparator_intAndDouble_returnsCorrectComparisonInt() { val lhsValue = createIntegerReal(lhsInt) val rhsValue = createIrrationalReal(rhsDouble) @@ -2415,17 +2286,15 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0", "lhsFrac=0", "rhsInt=0", "expInt=0"), - Iteration("-3/2<0", "lhsFrac=-3/2", "rhsInt=0", "expInt=-1"), - Iteration("-7/2<-3", "lhsFrac=-7/2", "rhsInt=-3", "expInt=-1"), - Iteration("-3/2>-5", "lhsFrac=-3/2", "rhsInt=-5", "expInt=1"), - Iteration("3/2>0", "lhsFrac=3/2", "rhsInt=0", "expInt=1"), - Iteration("7/2>3", "lhsFrac=7/2", "rhsInt=3", "expInt=1"), - Iteration("3/2<5", "lhsFrac=3/2", "rhsInt=5", "expInt=-1"), - Iteration("-3/2<3", "lhsFrac=-3/2", "rhsInt=3", "expInt=-1"), - Iteration("3/2>-3", "lhsFrac=3/2", "rhsInt=-3", "expInt=1") - ) + @Iteration("0==0", "lhsFrac=0", "rhsInt=0", "expInt=0") + @Iteration("-3/2<0", "lhsFrac=-3/2", "rhsInt=0", "expInt=-1") + @Iteration("-7/2<-3", "lhsFrac=-7/2", "rhsInt=-3", "expInt=-1") + @Iteration("-3/2>-5", "lhsFrac=-3/2", "rhsInt=-5", "expInt=1") + @Iteration("3/2>0", "lhsFrac=3/2", "rhsInt=0", "expInt=1") + @Iteration("7/2>3", "lhsFrac=7/2", "rhsInt=3", "expInt=1") + @Iteration("3/2<5", "lhsFrac=3/2", "rhsInt=5", "expInt=-1") + @Iteration("-3/2<3", "lhsFrac=-3/2", "rhsInt=3", "expInt=-1") + @Iteration("3/2>-3", "lhsFrac=3/2", "rhsInt=-3", "expInt=1") fun testComparator_fractionAndInt_returnsCorrectComparisonInt() { val lhsValue = createRationalReal(lhsFrac) val rhsValue = createIntegerReal(rhsInt) @@ -2436,16 +2305,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0", "lhsFrac=0", "rhsFrac=0", "expInt=0"), - Iteration("-3/2<0", "lhsFrac=-3/2", "rhsFrac=0", "expInt=-1"), - Iteration("-7/2<-3/2", "lhsFrac=-7/2", "rhsFrac=-3/2", "expInt=-1"), - Iteration("3/2>0", "lhsFrac=3/2", "rhsFrac=0", "expInt=1"), - Iteration("7/2>3/2", "lhsFrac=7/2", "rhsFrac=3/2", "expInt=1"), - Iteration("3/2<7/2", "lhsFrac=3/2", "rhsFrac=7/2", "expInt=-1"), - Iteration("-3/2<3/2", "lhsFrac=-3/2", "rhsFrac=3/2", "expInt=-1"), - Iteration("3/2>-3/2", "lhsFrac=3/2", "rhsFrac=-3/2", "expInt=1") - ) + @Iteration("0==0", "lhsFrac=0", "rhsFrac=0", "expInt=0") + @Iteration("-3/2<0", "lhsFrac=-3/2", "rhsFrac=0", "expInt=-1") + @Iteration("-7/2<-3/2", "lhsFrac=-7/2", "rhsFrac=-3/2", "expInt=-1") + @Iteration("3/2>0", "lhsFrac=3/2", "rhsFrac=0", "expInt=1") + @Iteration("7/2>3/2", "lhsFrac=7/2", "rhsFrac=3/2", "expInt=1") + @Iteration("3/2<7/2", "lhsFrac=3/2", "rhsFrac=7/2", "expInt=-1") + @Iteration("-3/2<3/2", "lhsFrac=-3/2", "rhsFrac=3/2", "expInt=-1") + @Iteration("3/2>-3/2", "lhsFrac=3/2", "rhsFrac=-3/2", "expInt=1") fun testComparator_fractionAndFraction_returnsCorrectComparisonInt() { val lhsValue = createRationalReal(lhsFrac) val rhsValue = createRationalReal(rhsFrac) @@ -2456,16 +2323,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0", "lhsFrac=0", "rhsDouble=0.0", "expInt=0"), - Iteration("-3/2<0", "lhsFrac=-3/2", "rhsDouble=0.0", "expInt=-1"), - Iteration("-7/2<-3.14", "lhsFrac=-7/2", "rhsDouble=-3.14", "expInt=-1"), - Iteration("3/2>0", "lhsFrac=3/2", "rhsDouble=0.0", "expInt=1"), - Iteration("7/2>3.14", "lhsFrac=7/2", "rhsDouble=3.14", "expInt=1"), - Iteration("3/2<3.14", "lhsFrac=3/2", "rhsDouble=3.14", "expInt=-1"), - Iteration("-3/2<3.14", "lhsFrac=-3/2", "rhsDouble=3.14", "expInt=-1"), - Iteration("3/2>-3.14", "lhsFrac=3/2", "rhsDouble=-3.14", "expInt=1") - ) + @Iteration("0==0", "lhsFrac=0", "rhsDouble=0.0", "expInt=0") + @Iteration("-3/2<0", "lhsFrac=-3/2", "rhsDouble=0.0", "expInt=-1") + @Iteration("-7/2<-3.14", "lhsFrac=-7/2", "rhsDouble=-3.14", "expInt=-1") + @Iteration("3/2>0", "lhsFrac=3/2", "rhsDouble=0.0", "expInt=1") + @Iteration("7/2>3.14", "lhsFrac=7/2", "rhsDouble=3.14", "expInt=1") + @Iteration("3/2<3.14", "lhsFrac=3/2", "rhsDouble=3.14", "expInt=-1") + @Iteration("-3/2<3.14", "lhsFrac=-3/2", "rhsDouble=3.14", "expInt=-1") + @Iteration("3/2>-3.14", "lhsFrac=3/2", "rhsDouble=-3.14", "expInt=1") fun testComparator_fractionAndDouble_returnsCorrectComparisonInt() { val lhsValue = createRationalReal(lhsFrac) val rhsValue = createIrrationalReal(rhsDouble) @@ -2476,16 +2341,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0", "lhsDouble=0.0", "rhsInt=0", "expInt=0"), - Iteration("-3.14<0", "lhsDouble=-3.14", "rhsInt=0", "expInt=-1"), - Iteration("-6.28<-4", "lhsDouble=-6.28", "rhsInt=-4", "expInt=-1"), - Iteration("3.14>0", "lhsDouble=3.14", "rhsInt=0", "expInt=1"), - Iteration("6.28>4", "lhsDouble=6.28", "rhsInt=4", "expInt=1"), - Iteration("3.14<4", "lhsDouble=3.14", "rhsInt=4", "expInt=-1"), - Iteration("-3.14<4", "lhsDouble=-3.14", "rhsInt=4", "expInt=-1"), - Iteration("3.14>-4", "lhsDouble=3.14", "rhsInt=-4", "expInt=1") - ) + @Iteration("0==0", "lhsDouble=0.0", "rhsInt=0", "expInt=0") + @Iteration("-3.14<0", "lhsDouble=-3.14", "rhsInt=0", "expInt=-1") + @Iteration("-6.28<-4", "lhsDouble=-6.28", "rhsInt=-4", "expInt=-1") + @Iteration("3.14>0", "lhsDouble=3.14", "rhsInt=0", "expInt=1") + @Iteration("6.28>4", "lhsDouble=6.28", "rhsInt=4", "expInt=1") + @Iteration("3.14<4", "lhsDouble=3.14", "rhsInt=4", "expInt=-1") + @Iteration("-3.14<4", "lhsDouble=-3.14", "rhsInt=4", "expInt=-1") + @Iteration("3.14>-4", "lhsDouble=3.14", "rhsInt=-4", "expInt=1") fun testComparator_doubleAndInt_returnsCorrectComparisonInt() { val lhsValue = createIrrationalReal(lhsDouble) val rhsValue = createIntegerReal(rhsInt) @@ -2496,16 +2359,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0", "lhsDouble=0.0", "rhsFrac=0", "expInt=0"), - Iteration("-3.14<0", "lhsDouble=-3.14", "rhsFrac=0", "expInt=-1"), - Iteration("-6.28<-7/2", "lhsDouble=-6.28", "rhsFrac=-7/2", "expInt=-1"), - Iteration("3.14>0", "lhsDouble=3.14", "rhsFrac=0", "expInt=1"), - Iteration("6.28>7/2", "lhsDouble=6.28", "rhsFrac=7/2", "expInt=1"), - Iteration("3.14<7/2", "lhsDouble=3.14", "rhsFrac=7/2", "expInt=-1"), - Iteration("-3.14<7/2", "lhsDouble=-3.14", "rhsFrac=7/2", "expInt=-1"), - Iteration("3.14>-7/2", "lhsDouble=3.14", "rhsFrac=-7/2", "expInt=1") - ) + @Iteration("0==0", "lhsDouble=0.0", "rhsFrac=0", "expInt=0") + @Iteration("-3.14<0", "lhsDouble=-3.14", "rhsFrac=0", "expInt=-1") + @Iteration("-6.28<-7/2", "lhsDouble=-6.28", "rhsFrac=-7/2", "expInt=-1") + @Iteration("3.14>0", "lhsDouble=3.14", "rhsFrac=0", "expInt=1") + @Iteration("6.28>7/2", "lhsDouble=6.28", "rhsFrac=7/2", "expInt=1") + @Iteration("3.14<7/2", "lhsDouble=3.14", "rhsFrac=7/2", "expInt=-1") + @Iteration("-3.14<7/2", "lhsDouble=-3.14", "rhsFrac=7/2", "expInt=-1") + @Iteration("3.14>-7/2", "lhsDouble=3.14", "rhsFrac=-7/2", "expInt=1") fun testComparator_doubleAndFraction_returnsCorrectComparisonInt() { val lhsValue = createIrrationalReal(lhsDouble) val rhsValue = createRationalReal(rhsFrac) @@ -2516,16 +2377,14 @@ class RealExtensionsTest { } @Test - @RunParameterized( - Iteration("0==0", "lhsDouble=0.0", "rhsDouble=0.0", "expInt=0"), - Iteration("-3.14<0", "lhsDouble=-3.14", "rhsDouble=0.0", "expInt=-1"), - Iteration("-6.28<-3.14", "lhsDouble=-6.28", "rhsDouble=-3.14", "expInt=-1"), - Iteration("3.14>0", "lhsDouble=3.14", "rhsDouble=0.0", "expInt=1"), - Iteration("6.28>3.14", "lhsDouble=6.28", "rhsDouble=3.14", "expInt=1"), - Iteration("3.14<6.28", "lhsDouble=3.14", "rhsDouble=6.28", "expInt=-1"), - Iteration("-3.14<6.28", "lhsDouble=-3.14", "rhsDouble=6.28", "expInt=-1"), - Iteration("3.14>-6.28", "lhsDouble=3.14", "rhsDouble=-6.28", "expInt=1") - ) + @Iteration("0==0", "lhsDouble=0.0", "rhsDouble=0.0", "expInt=0") + @Iteration("-3.14<0", "lhsDouble=-3.14", "rhsDouble=0.0", "expInt=-1") + @Iteration("-6.28<-3.14", "lhsDouble=-6.28", "rhsDouble=-3.14", "expInt=-1") + @Iteration("3.14>0", "lhsDouble=3.14", "rhsDouble=0.0", "expInt=1") + @Iteration("6.28>3.14", "lhsDouble=6.28", "rhsDouble=3.14", "expInt=1") + @Iteration("3.14<6.28", "lhsDouble=3.14", "rhsDouble=6.28", "expInt=-1") + @Iteration("-3.14<6.28", "lhsDouble=-3.14", "rhsDouble=6.28", "expInt=-1") + @Iteration("3.14>-6.28", "lhsDouble=3.14", "rhsDouble=-6.28", "expInt=1") fun testComparator_doubleAndDouble_returnsCorrectComparisonInt() { val lhsValue = createIrrationalReal(lhsDouble) val rhsValue = createIrrationalReal(rhsDouble) diff --git a/utility/src/test/java/org/oppia/android/util/profile/ProfileNameValidatorTest.kt b/utility/src/test/java/org/oppia/android/util/profile/ProfileNameValidatorTest.kt index 7dbbceee779..2875834c868 100644 --- a/utility/src/test/java/org/oppia/android/util/profile/ProfileNameValidatorTest.kt +++ b/utility/src/test/java/org/oppia/android/util/profile/ProfileNameValidatorTest.kt @@ -11,7 +11,6 @@ import org.junit.runner.RunWith import org.oppia.android.testing.junit.OppiaParameterizedTestRunner import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Iteration import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.Parameter -import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.RunParameterized import org.oppia.android.testing.junit.OppiaParameterizedTestRunner.SelectRunnerPlatform import org.oppia.android.testing.junit.ParameterizedRobolectricTestRunner import org.oppia.android.testing.robolectric.RobolectricModule @@ -50,32 +49,26 @@ class ProfileNameValidatorTest { } @Test - @RunParameterized( - Iteration("Ben#Henning", "name=Ben#Henning"), - Iteration("Rajay@T", "name=Rajay@T"), - Iteration("جيشنو^&&", "name=جيشنو^&&"), - Iteration("_Jishnu", "name=_Jishnu") - ) + @Iteration("Ben#Henning", "name=Ben#Henning") + @Iteration("Rajay@T", "name=Rajay@T") + @Iteration("جيشنو^&&", "name=جيشنو^&&") + @Iteration("_Jishnu", "name=_Jishnu") fun testIsNameValid_nameWithDisallowedSymbol_returnsFalse() { assertThat(profileNameValidator.isNameValid(name)).isFalse() } @Test - @RunParameterized( - Iteration("Ben-Henning", "name=Ben-Henning"), - Iteration("Rajat.T", "name=Rajat.T"), - Iteration("G'Jishnu", "name=G'Jishnu") - ) + @Iteration("Ben-Henning", "name=Ben-Henning") + @Iteration("Rajat.T", "name=Rajat.T") + @Iteration("G'Jishnu", "name=G'Jishnu") fun testIsNameValid_nameWithAllowedSymbols_returnsTrue() { assertThat(profileNameValidator.isNameValid(name)).isTrue() } @Test - @RunParameterized( - Iteration("Ben-.Henning", "name=Ben-.Henning"), - Iteration("Rajat..T", "name=Rajat..T"), - Iteration("Name WithTooManySpaces", "name=Name WithTooManySpaces") - ) + @Iteration("Ben-.Henning", "name=Ben-.Henning") + @Iteration("Rajat..T", "name=Rajat..T") + @Iteration("Name WithTooManySpaces", "name=Name WithTooManySpaces") fun testIsNameValid_nameWithRepeatedAllowedSymbols_returnsFalse() { assertThat(profileNameValidator.isNameValid(name)).isFalse() } diff --git a/wiki/Dagger.md b/wiki/Dagger.md index a9d133dfe07..1c8aabe7fe5 100644 --- a/wiki/Dagger.md +++ b/wiki/Dagger.md @@ -106,13 +106,13 @@ class DispatcherModule { Here is an example of testing with Oppia Dagger. This shows setting up a test component and using it to inject dependencies for testing purposes. It also shows how to create a test-specific dependency that can be injected into a test for manipulation. ``` class InMemoryBlockingCacheTest { - @ExperimentalCoroutinesApi @Inject @field:TestDispatcher lateinit var testDispatcher: TestCoroutineDispatcher - @ExperimentalCoroutinesApi private val backgroundTestCoroutineScope by lazy { CoroutineScope(backgroundTestCoroutineDispatcher) } - @ExperimentalCoroutinesApi private val backgroundTestCoroutineDispatcher by lazy { TestCoroutineDispatcher() } + @field:[Inject TestDispatcher] lateinit var testDispatcher: TestCoroutineDispatcher + private val backgroundTestCoroutineScope by lazy { CoroutineScope(backgroundTestCoroutineDispatcher) } + private val backgroundTestCoroutineDispatcher by lazy { TestCoroutineDispatcher() } - @Before @ExperimentalCoroutinesApi fun setUp() { setUpTestApplicationComponent() } + @Before fun setUp() { setUpTestApplicationComponent() } - @Test @ExperimentalCoroutinesApi fun `test with testDispatcher since it's connected to the blocking dispatcher`() = runBlockingTest(testDispatcher) { /* ... */ } + @Test fun `test with testDispatcher since it's connected to the blocking dispatcher`() = runBlockingTest(testDispatcher) { /* ... */ } private fun setUpTestApplicationComponent() { DaggerInMemoryBlockingCacheTest_TestApplicationComponent.builder().setApplication(ApplicationProvider.getApplicationContext()).build().inject(this) @@ -121,8 +121,8 @@ class InMemoryBlockingCacheTest { @Qualifier annotation class TestDispatcher @Module class TestModule { - @ExperimentalCoroutinesApi @Singleton @Provides @TestDispatcher fun provideTestDispatcher(): TestCoroutineDispatcher { return TestCoroutineDispatcher() } - @ExperimentalCoroutinesApi @Singleton @Provides @BlockingDispatcher + @Singleton @Provides @TestDispatcher fun provideTestDispatcher(): TestCoroutineDispatcher { return TestCoroutineDispatcher() } + @Singleton @Provides @BlockingDispatcher fun provideBlockingDispatcher(@TestDispatcher testDispatcher: TestCoroutineDispatcher): CoroutineDispatcher { return testDispatcher } } diff --git a/wiki/Work-Manager.md b/wiki/Work-Manager.md index 2547ee7b457..ce9628d217f 100644 --- a/wiki/Work-Manager.md +++ b/wiki/Work-Manager.md @@ -49,7 +49,6 @@ If you want to introduce a new feature or any change to the existing WorkManager ... @BackgroundDispatcher private val backgroundDispatcher: CoroutineDispatcher ) : ListenableWorker(context, params) { - @ExperimentalCoroutinesApi override fun startWork(): ListenableFuture { val backgroundScope = CoroutineScope(backgroundDispatcher) val result = backgroundScope.async {...}