[0-9\.]{10}).*?09:15<\/td> | (?.*?)<\/td>.*?12:15<\/td> | (?.*?)<\/td>
+attr GeoTest get01Replacement01Value {strftime("%d.%m.%Y", localtime( time))}
+attr GeoTest getURL file://geocache-planer.de/CAL/anmeldung.php?date=%%date%%&CALID=XYZ
+attr GeoTest replacement01Mode expression
+attr GeoTest replacement01Regex %%date%%
+
diff --git a/fhem/t/FHEM/98_HTTPMOD/50_Replacements.t b/fhem/t/FHEM/98_HTTPMOD/50_Replacements.t
new file mode 100644
index 000000000..57cd1b07d
--- /dev/null
+++ b/fhem/t/FHEM/98_HTTPMOD/50_Replacements.t
@@ -0,0 +1,18 @@
+##############################################
+# test replacements
+#
+##############################################
+use strict;
+use warnings;
+use Test::More;
+
+fhem('set GeoTest reread');
+
+
+InternalTimer(time()+1, sub() {
+ is(FhemTestUtils_gotLog(qr/Read callback: Error: geocache\-planer.*date=[\d]+\.\d+\.\d+/), 1, "Expr replacement in URL");
+ done_testing;
+ exit(0);
+}, 0);
+
+1;
diff --git a/fhem/t/FHEM/98_HTTPMOD/99_evalExpr.cfg b/fhem/t/FHEM/98_HTTPMOD/99_evalExpr.cfg
new file mode 100644
index 000000000..1d099cc00
--- /dev/null
+++ b/fhem/t/FHEM/98_HTTPMOD/99_evalExpr.cfg
@@ -0,0 +1,4 @@
+define H2 HTTPMOD file://t/FHEM/98_HTTPMOD/JSON 0
+attr H2 verbose 3
+attr H2 get01Name TestGet
+attr H2 get01Data Post Data for Test
diff --git a/fhem/t/FHEM/98_HTTPMOD/99_evalExpr.t b/fhem/t/FHEM/98_HTTPMOD/99_evalExpr.t
new file mode 100644
index 000000000..556b03b98
--- /dev/null
+++ b/fhem/t/FHEM/98_HTTPMOD/99_evalExpr.t
@@ -0,0 +1,36 @@
+##############################################
+# test evalExpr Util function
+##############################################
+use strict;
+use warnings;
+use Test::More;
+
+use_ok ('FHEM::HTTPMOD::Utils', qw(:all));
+
+my $hash = $defs{'H2'};
+my $name = 'H2';
+my $val = 5;
+my @array = (1,2,3);
+my %tHash = (a => 10, b => 20);
+my $exp = '$val * 2';
+
+my $result = EvalExpr($hash, $exp, {'$val' => $val, '@array' => \@array});
+#Log3 $name, 3, "$name: result of EvalExpr test 1 = $result";
+is $result, 10, "simple expression with one scalar in list";
+
+$exp = '$array[1] * 2';
+$result = EvalExpr($hash, $exp, {'$val' => $val, '@array' => \@array});
+is $result, 4, "simple expression with array ref in hash";
+
+$exp = '$hash{a} * 2';
+$result = EvalExpr($hash, $exp, {'$val' => $val, '%hash' => \%tHash});
+is $result, 20, "simple expression with hash ref in hash";
+
+$exp = '$hash->{a} * 2';
+$result = EvalExpr($hash, $exp, {'$val' => $val, '$hash' => \%tHash});
+is $result, 20, "simple expression with hash ref as ref in hash";
+
+done_testing;
+exit(0);
+
+1;
| |