Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 24... Línea 24...
24
 * @package   mod_lesson
24
 * @package   mod_lesson
25
 * @category  test
25
 * @category  test
26
 * @copyright 2020 Peter Dias
26
 * @copyright 2020 Peter Dias
27
 * @license   http://www.gnu.org/copyleft/gpl.html GNU Public License
27
 * @license   http://www.gnu.org/copyleft/gpl.html GNU Public License
28
 */
28
 */
29
class numeric_helper_test extends \advanced_testcase {
29
final class numeric_helper_test extends \advanced_testcase {
30
    /**
30
    /**
31
     * Test the lesson_unformat_numeric_value function.
31
     * Test the lesson_unformat_numeric_value function.
32
     *
32
     *
33
     * @dataProvider lesson_unformat_dataprovider
33
     * @dataProvider lesson_unformat_dataprovider
34
     * @param $decsep
34
     * @param $decsep
Línea 60... Línea 60...
60
    /**
60
    /**
61
     * Provide various cases for the unformat test function
61
     * Provide various cases for the unformat test function
62
     *
62
     *
63
     * @return array
63
     * @return array
64
     */
64
     */
65
    public function lesson_unformat_dataprovider() {
65
    public static function lesson_unformat_dataprovider(): array {
66
        return [
66
        return [
67
            "Using a decimal as a separator" => [
67
            "Using a decimal as a separator" => [
68
                "decsep" => ".",
68
                "decsep" => ".",
69
                "test" => [
69
                "tests" => [
70
                    ["2.1", 2.1],
70
                    ["2.1", 2.1],
71
                    ["1:4.2", "1:4.2"],
71
                    ["1:4.2", "1:4.2"],
72
                    ["2,1", 2],
72
                    ["2,1", 2],
73
                    ["1:4,2", "1:4"],
73
                    ["1:4,2", "1:4"],
74
                    ["", null]
74
                    ["", null]
75
                ]
75
                ]
76
            ],
76
            ],
77
            "Using a comma as a separator" => [
77
            "Using a comma as a separator" => [
78
                "decsep" => ",",
78
                "decsep" => ",",
79
                "test" => [
79
                "tests" => [
80
                    ["2,1", 2.1],
80
                    ["2,1", 2.1],
81
                    ["1:4,2", "1:4.2"],
81
                    ["1:4,2", "1:4.2"],
82
                    ["2.1", 2.1],
82
                    ["2.1", 2.1],
83
                    ["1:4.2", "1:4.2"],
83
                    ["1:4.2", "1:4.2"],
84
                ]
84
                ]
85
            ],
85
            ],
86
            "Using a X as a separator" => [
86
            "Using a X as a separator" => [
87
                "decsep" => "X",
87
                "decsep" => "X",
88
                "test" => [
88
                "tests" => [
89
                    ["2X1", 2.1],
89
                    ["2X1", 2.1],
90
                    ["1:4X2", "1:4.2"],
90
                    ["1:4X2", "1:4.2"],
91
                    ["2.1", 2.1],
91
                    ["2.1", 2.1],
92
                    ["1:4.2", "1:4.2"],
92
                    ["1:4.2", "1:4.2"],
93
                ]
93
                ]
Línea 98... Línea 98...
98
    /**
98
    /**
99
     * Provide various cases for the unformat test function
99
     * Provide various cases for the unformat test function
100
     *
100
     *
101
     * @return array
101
     * @return array
102
     */
102
     */
103
    public function lesson_format_dataprovider() {
103
    public static function lesson_format_dataprovider(): array {
104
        return [
104
        return [
105
            "Using a decimal as a separator" => [
105
            "Using a decimal as a separator" => [
106
                "decsep" => ".",
106
                "decsep" => ".",
107
                "test" => [
107
                "tests" => [
108
                    ["2.1", 2.1],
108
                    ["2.1", 2.1],
109
                    ["1:4.2", "1:4.2"],
109
                    ["1:4.2", "1:4.2"],
110
                    ["2,1", "2,1"],
110
                    ["2,1", "2,1"],
111
                    ["1:4,2", "1:4,2"]
111
                    ["1:4,2", "1:4,2"]
112
                ]
112
                ]
113
            ],
113
            ],
114
            "Using a comma as a separator" => [
114
            "Using a comma as a separator" => [
115
                "decsep" => ",",
115
                "decsep" => ",",
116
                "test" => [
116
                "tests" => [
117
                    ["2,1", "2,1"],
117
                    ["2,1", "2,1"],
118
                    ["1:4,2", "1:4,2"],
118
                    ["1:4,2", "1:4,2"],
119
                    ["2.1", "2,1"],
119
                    ["2.1", "2,1"],
120
                    [2.1, "2,1"],
120
                    [2.1, "2,1"],
121
                    ["1:4.2", "1:4,2"],
121
                    ["1:4.2", "1:4,2"],
122
                ]
122
                ]
123
            ],
123
            ],
124
            "Using a X as a separator" => [
124
            "Using a X as a separator" => [
125
                "decsep" => "X",
125
                "decsep" => "X",
126
                "test" => [
126
                "tests" => [
127
                    ["2X1", "2X1"],
127
                    ["2X1", "2X1"],
128
                    ["1:4X2", "1:4X2"],
128
                    ["1:4X2", "1:4X2"],
129
                    ["2.1", "2X1"],
129
                    ["2.1", "2X1"],
130
                    ["1:4.2", "1:4X2"],
130
                    ["1:4.2", "1:4X2"],
131
                ]
131
                ]