瀏覽代碼

Use strict equality in generated JS (#750)

jonatan 2 年之前
父節點
當前提交
e811a84ed4
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 2 2
      pynecone/var.py
  2. 2 2
      tests/test_var.py

+ 2 - 2
pynecone/var.py

@@ -373,7 +373,7 @@ class Var(ABC):
         Returns:
             A var representing the equality comparison.
         """
-        return self.compare("==", other)
+        return self.compare("===", other)
 
     def __ne__(self, other: Var) -> Var:
         """Perform an inequality comparison.
@@ -384,7 +384,7 @@ class Var(ABC):
         Returns:
             A var representing the inequality comparison.
         """
-        return self.compare("!=", other)
+        return self.compare("!==", other)
 
     def __gt__(self, other: Var) -> Var:
         """Perform a greater than comparison.

+ 2 - 2
tests/test_var.py

@@ -167,8 +167,8 @@ def test_basic_operations(TestObj):
     Args:
         TestObj: The test object.
     """
-    assert str(v(1) == v(2)) == "{(1 == 2)}"
-    assert str(v(1) != v(2)) == "{(1 != 2)}"
+    assert str(v(1) == v(2)) == "{(1 === 2)}"
+    assert str(v(1) != v(2)) == "{(1 !== 2)}"
     assert str(v(1) < v(2)) == "{(1 < 2)}"
     assert str(v(1) <= v(2)) == "{(1 <= 2)}"
     assert str(v(1) > v(2)) == "{(1 > 2)}"